No Description
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.

lib.rs 327B

12345678910111213141516171819
  1. pub fn square_of_sum(n: i32) -> i32 {
  2. let mut i: i32 = 0;
  3. for x in 1..n + 1 {
  4. i += x;
  5. }
  6. i.pow(2)
  7. }
  8. pub fn sum_of_squares(n: i32) -> i32 {
  9. let mut i: i32 = 0;
  10. for x in 1..n + 1 {
  11. i += x.pow(2);
  12. }
  13. i
  14. }
  15. pub fn difference(n: i32) -> i32 {
  16. square_of_sum(n) - sum_of_squares(n)
  17. }