euler_approximation.nbt 188 B

12345678
  1. # Compute the number e from 1/0! + 1/1! + 1/2! + 1/3! + …
  2. fn approx_e(n: Scalar) -> Scalar =
  3. if n == 0
  4. then 1
  5. else 1 / n! + approx_e(n - 1)
  6. assert_eq(approx_e(20), e, 1e-10)