oily-solutions/sum_square_difference.rs

15 lines
257 B
Rust
Raw Normal View History

2024-11-20 10:06:59 +00:00
fn main() {
let mut total: u64 = 0;
let mut total1: u64 = 0;
for i in 1..=100 {
2024-11-20 20:44:03 +00:00
total += i * i;
2024-11-20 10:06:59 +00:00
total1 += i;
}
let square_sum = total1.pow(2);
2024-11-20 20:44:03 +00:00
let difference = square_sum - total;
2024-11-20 10:06:59 +00:00
println!("{}", difference);
}