1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Swiftでネイピア数を求める。

Posted at
func exp(_ x: Double) -> Double {
    if abs(x) < 1e-12 {
        return 1 + x
    }
    let a = exp(x/2)
    return a*a
}

print(exp(1)) // 2.718281808182473

理論値: $e = 2.71828 18284 59045 23536 02874 71352$

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?