Skip to content

Instantly share code, notes, and snippets.

@RandyMcMillan
Forked from rust-play/playground.rs
Last active January 10, 2025 16:29
Show Gist options
  • Save RandyMcMillan/ab581eb3efb261e20f740409ca0fe591 to your computer and use it in GitHub Desktop.
Save RandyMcMillan/ab581eb3efb261e20f740409ca0fe591 to your computer and use it in GitHub Desktop.
pi_pow.rs
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