CT080

Sum Square Difference

EasyAcceptance: 0.0%

The sum of the squares of the first n natural numbers is 1^2 + 2^2 + ... + n^2. The square of the sum is (1 + 2 + ... + n)^2. Find the difference between the square of the sum and the sum of the squares for the first n natural numbers.

Example 1:

Input: 10
Output: 2640

Example 2:

Input: 100
Output: 25164150

Example 3:

Input: 20
Output: 41230

Constraints:

1 <= n <= 10^4

Tags:

math arithmetic series
Loading...
Test Cases:No test cases
No test cases available.
Coding Problem Not Found | CodeTikki