From 49a87c045cf45ba4f144456bb2c6809dd41c43eb Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Wed, 20 Nov 2024 11:58:40 +0000 Subject: [PATCH] solutions: 9 --- special_pythagorean_triplet.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 special_pythagorean_triplet.rs diff --git a/special_pythagorean_triplet.rs b/special_pythagorean_triplet.rs new file mode 100644 index 0000000..3267fe1 --- /dev/null +++ b/special_pythagorean_triplet.rs @@ -0,0 +1,17 @@ +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.) { + if i+j+k == 1000 { + println!("{}", i*j*k); + break 'algorithm; + } + } + } + } + } + } +}