Challenges

Sum of square

Intro to Programming

sumSquareDifference.js

The sum of the squares of the first ten natural numbers is 12 + 22 + 32 + ... + 10 2 = 385.

The square of the sum of the first ten natural numbers is (1 + 2 + 3 + ... + 10)2 = 552 = 3025.

Hence the difference between the square of the sum and the sum of the squares of the first ten natural numbers is 3025 − 385 = 2640.

Write the sumSquareDifference function that takes argument n and returns the difference between the square of the sum and the sum of the squares of first n natural numbers.

Start challenge Successful completion: 96%

Last code review

User Updated at Submissions count
krivtsov 09 Mar 09:41 1