From 10a975e9782e38188ba5da0074e9549c25d0f7f7 Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Wed, 20 Nov 2024 10:06:59 +0000 Subject: [PATCH] solutions: 6 --- sum_square_difference.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 sum_square_difference.rs diff --git a/sum_square_difference.rs b/sum_square_difference.rs new file mode 100644 index 0000000..b8dd0fc --- /dev/null +++ b/sum_square_difference.rs @@ -0,0 +1,14 @@ +fn main() { + let mut total: u64 = 0; + let mut total1: u64 = 0; + + for i in 1..=100 { + total += i*i; + total1 += i; + } + + let square_sum = total1.pow(2); + let difference = square_sum-total; + + println!("{}", difference); +}