Kotlin exp()

Anonymous contributor's avatar
Anonymous contributor
Published Oct 27, 2023
Contribute to Docs

The exp() method in Kotlin’s math class is used to calculate Euler’s number e raised to the power of a given number.

  • 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

exp(number)
  • number: A number of type Double or Float. The method returns a number, of the same type given.

Example

This example demonstrates a basic implementation of the exp() method.

import kotlin.math.exp
fun main() {
val number = 3.0
val ePowNumber = exp(number)
println("Euler's number e raised to the power of $number is $ePowNumber.")
}

The code above will result in the following output:

Euler's number e raised to the power of 3.0 is 20.085536923187668.

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