32 Program to find sum of first 'n' no's using while loop in Python

Program:

#program to find sum of first 'n' no's using while

n=int(input("enter value of n"))

x=1

sum=0

while (x<=n):

    sum=sum+x

    x=x+1

print(sum)


Output:

Program to find sum of first 'n' no's using while loop in Python

Previous
Next Post »