Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created January 8, 2025 15:30
Show Gist options
  • Save rust-play/0906bccc10e580d2555b975c1a177b8d to your computer and use it in GitHub Desktop.
Save rust-play/0906bccc10e580d2555b975c1a177b8d to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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