Square number series



Problem to square the number from 1 to given number. Then we want to sum all the squared number.



Example-1:


Input    : n = 5
Output   : 55
Explain  : 12+22+32+42+52 = 55.


Example-2:


Input    : n = 4
Output   : 30 
Explain  : 12+22+32+42 = 30.







Solution





n = 5

k = 0

for i in range(1,n+1):

    k += int(i)**2

print(k)



Output



55