Skip to content

Commit 270f9a0

Browse files
authored
Create SumOfNatural.py
iven a positive integer N. The task is to find 12 + 22 + 32 + ….. + N2.
1 parent bc155e1 commit 270f9a0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

SumOfNatural.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
def squaresum(n) :
3+
4+
5+
sm = 0
6+
for i in range(1, n+1) :
7+
sm = sm + (i * i)
8+
9+
return sm
10+
11+
n = 4
12+
print(squaresum(n))

0 commit comments

Comments
 (0)