You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
| 12345678910111213141516171819 |
- pub fn square_of_sum(n: i32) -> i32 {
- let mut i: i32 = 0;
- for x in 1..n + 1 {
- i += x;
- }
- i.pow(2)
- }
-
- pub fn sum_of_squares(n: i32) -> i32 {
- let mut i: i32 = 0;
- for x in 1..n + 1 {
- i += x.pow(2);
- }
- i
- }
-
- pub fn difference(n: i32) -> i32 {
- square_of_sum(n) - sum_of_squares(n)
- }
|