feat: add pi

This commit is contained in:
2024-03-24 00:30:31 +08:00
parent e5748b1e41
commit 930c35abff
3 changed files with 22 additions and 0 deletions

7
__std/pi/src/main.rs Normal file
View File

@@ -0,0 +1,7 @@
fn main() {
let mut pi = 1f64;
for i in 1..1000000000u64 {
pi += if i % 2 == 1 { -1f64 } else { 1f64 } / (1f64 + i as f64 * 2f64);
}
println!("pi = {}", pi * 4f64);
}