Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save magneticleaves/b7796811999fd2d99c7830067427ec03 to your computer and use it in GitHub Desktop.
Save magneticleaves/b7796811999fd2d99c7830067427ec03 to your computer and use it in GitHub Desktop.
e taylor series
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