Kotlin cbrt()
Published Oct 18, 2023Updated Jun 11, 2025
Contribute to Docs
The math.cbrt() method returns the cube root of the given argument.
Syntax
cbrt(n)
nrefers to the number passed to the method of typeDoubleorFloat.
Example
The following example uses cbrt() to return the cube roots of -6.5, 2, and -340.8:
// version 1.1.2import kotlin.math.cbrtfun main(args: Array<String>) {val x = -6.5val y = 2.0val z = -340.8println("The cube root of $x is ${cbrt(x)}")println("The cube root of $y is ${cbrt(y)}")println("The cube root of $z is ${cbrt(z)}")}
This produces the following output:
The cube root of -6.5 is -1.862518585537463The cube root of 2.0 is 1.2599210498948732The cube root of -340.8 is -6.928203230275508
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Kotlin on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn Kotlin, the expressive, open-source programming language developed by JetBrains.
- Beginner Friendly.9 hours