20.WAP to find sum of the first n natural number

CODE:

n=int(input("Enter the Value oF n\n"))

sum=0

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

    sum=sum+i

print("Sum of",n,"natural number is",sum )

OUTPUT:

Enter the Value oF n

5

Sum of 5 natural number is 15

Comments

Popular posts from this blog