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.

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