Pure Programmer
Blue Matrix


Cluster Map

Project: Calculate Euler's Number

You can calculate the value of [[E_(mathematical_constant)|Euler's Number]] (𝑒) using an infinite series that uses the factorial function.

`e = sum_(n=0)^oo 1/(n!)`

or

`e = 1 + 1/(1!) + 1/(2!) + 1/(3!) + 1/(4!) + 1/(5!) + ...`

where the factorial n! is:

`n! = 1*2*3*4*5*...*n`

Write a function to compute Euler's Number to a specified number of terms N that is passed to the function. Test the function with various values of N.

Output
$ rustc CalculateEulersNumber.rs error[E0308]: mismatched types --> CalculateEulersNumber.rs:9:28 | 9 | let mut denominator:f64 = 1; | --- ^ | | | | | expected `f64`, found integer | | help: use a float literal: `1.0` | expected due to this error: aborting due to previous error For more information about this error, try `rustc --explain E0308`.

Solution