Kotlin cbrt()

Sriparno08's avatar
Published Oct 18, 2023Updated Jun 11, 2025
Contribute to Docs

The math.cbrt() method returns the cube root of the given argument.

  • 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

Syntax

cbrt(n)
  • n refers to the number passed to the method of type Double or Float.

Example

The following example uses cbrt() to return the cube roots of -6.5, 2, and -340.8:

// version 1.1.2
import kotlin.math.cbrt
fun main(args: Array<String>) {
val x = -6.5
val y = 2.0
val z = -340.8
println("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.862518585537463
The cube root of 2.0 is 1.2599210498948732
The cube root of -340.8 is -6.928203230275508

All contributors

Contribute to 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