Skip to content

Commit 310ab27

Browse files
authored
Merge pull request sat5297#3 from aj-923/aj-923-patch-2
Create "sum of first n natural numbers.py"
2 parents b37627a + b5a3f7b commit 310ab27

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Python3 Program to
2+
# find sum of square
3+
# of first n natural
4+
# numbers
5+
6+
7+
# Return the sum of
8+
# square of first n
9+
# natural numbers
10+
def squaresum(n) :
11+
12+
sm = 0
13+
for i in range(1, n+1) :
14+
sm = sm + (i * i)
15+
return sm
16+
17+
# Driven Program
18+
n = input("enter the number upto which you want the sum of squares")
19+
print(squaresum(n))

0 commit comments

Comments
 (0)