Sum of squares for N natural numbers.

Posted on | Sunday, 14 May 2023 | No Comments

 Given a positive integer N, print the sum of squares of 1st N natural numbers.

Input Format

First and only line of input contains positive integer - N.

Constraints

1 <= N <= 103

Output Format

Print the sum of squares of 1st N natural numbers.

Sample Input 0

15

Sample Output 0

1240
code
n=int(input())
d=(2*n+1)
e=(n+1)
print(int((n*e*d)/6))

Comments

Leave a Reply

Search

Followers