Created
January 7, 2022 17:51
-
-
Save magneticleaves/b7796811999fd2d99c7830067427ec03 to your computer and use it in GitHub Desktop.
e taylor series
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let n = 35; | |
let mut e: f64 = 1.0; | |
for i in 1..n { e += (1.0 / factorial(i) as f64); } | |
println!("e value: {}", e); | |
} | |
fn factorial(mut n: u128) -> u128 { | |
let mut r = 1; | |
for i in 2..n+1 { r *= i; } | |
println!("fac({}) = {}", n, r); | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment