oily-solutions/special_pythagorean_triplet.rs

18 lines
518 B
Rust
Raw Normal View History

2024-11-20 11:58:40 +00:00
fn main() {
'algorithm: loop {
for i in 1..1000 {
for j in 1..1000 {
for k in 1..1000 {
let pythagoras: f64 = (i as f64).powf(2.) + (j as f64).powf(2.);
if pythagoras == (k as f64).powf(2.) {
2024-11-20 20:44:03 +00:00
if i + j + k == 1000 {
println!("{}", i * j * k);
2024-11-20 11:58:40 +00:00
break 'algorithm;
}
}
}
}
}
}
}