|
|
@ -3,7 +3,7 @@ fn main() { |
|
|
|
// SOLUTION 1
|
|
|
|
// SOLUTION 1
|
|
|
|
let mut sum_1 = 0; |
|
|
|
let mut sum_1 = 0; |
|
|
|
let mut sum_a = 0; |
|
|
|
let mut sum_a = 0; |
|
|
|
for i in 0..100 { |
|
|
|
for i in 0..=100 { |
|
|
|
sum_1 += i; |
|
|
|
sum_1 += i; |
|
|
|
sum_a += i * i; |
|
|
|
sum_a += i * i; |
|
|
|
} |
|
|
|
} |
|
|
@ -15,7 +15,7 @@ fn main() { |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// SOLUTION 2
|
|
|
|
// SOLUTION 2
|
|
|
|
let n = 99; |
|
|
|
let n = 100; |
|
|
|
let solution_2 = ( (n * (n + 1) ) / 2) * ( (n * (n + 1) ) / 2 ) - ( (n * (n + 1) * (2 * n + 1)) / 6 ); |
|
|
|
let solution_2 = ( (n * (n + 1) ) / 2) * ( (n * (n + 1) ) / 2 ) - ( (n * (n + 1) * (2 * n + 1)) / 6 ); |
|
|
|
println!("solution2: {}", solution_2); |
|
|
|
println!("solution2: {}", solution_2); |
|
|
|
} |
|
|
|
} |
|
|
|