Sum of Squares Up to N

00:00
Easyloopsarithmeticsummationbasic

Given a positive integer n, calculate the sum of the squares of all integers from 1 to n (inclusive).

For example:

If n = 1, the sum is 1*1 = 1. If n = 3, the sum is 1*1 + 2*2 + 3*3 = 1 + 4 + 9 = 14. If n = 5, the sum is 1*1 + 2*2 + 3*3 + 4*4 + 5*5 = 1 + 4 + 9 + 16 + 25 = 55.

Constraints:

  • 1 <= n <= 1000

Examples

Input → 1
Output → 1
Input → 3
Output → 14
Input → 5
Output → 55