-
-
Save RandyMcMillan/ab581eb3efb261e20f740409ca0fe591 to your computer and use it in GitHub Desktop.
pi_pow.rs
This file contains hidden or 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
use std::f64::consts::PI; | |
fn main() { | |
let mut sum = 0.0; | |
let mut term = 1.0; | |
let mut k = 0; | |
loop { | |
sum += term; | |
k += 1; | |
term *= PI * PI.ln() / k as f64; | |
if term.abs() < 1e-15 { | |
break; | |
} | |
} | |
println!("Pi to the power of Pi: {}", sum); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment