Exercism: Go version of the 'Difference of Squares' exercise.
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.

30 lines
846 B

9 years ago
  1. # Difference Of Squares
  2. Find the difference between the sum of the squares and the square of the sums of the first N natural numbers.
  3. The square of the sum of the first ten natural numbers is,
  4. (1 + 2 + ... + 10)**2 = 55**2 = 3025
  5. The sum of the squares of the first ten natural numbers is,
  6. 1**2 + 2**2 + ... + 10**2 = 385
  7. Hence the difference between the square of the sum of the first
  8. ten natural numbers and the sum of the squares is 2640:
  9. 3025 - 385 = 2640
  10. To run the tests simply run the command `go test` in the exercise directory.
  11. If the test suite contains benchmarks, you can run these with the `-bench`
  12. flag:
  13. go test -bench .
  14. For more detailed info about the Go track see the [help
  15. page](http://exercism.io/languages/go).
  16. ## Source
  17. Problem 6 at Project Euler [view source](http://projecteuler.net/problem=6)