Python Program to Print Sum of N Numbers Using While Loop

 Python Program to Print Sum of N Numbers Using while Loop


# Sum of n natural numbers using while loop
n=int(input("Enter Number:"))
sum=0
i=1 
while i<=n :
    sum=sum+i 
    i=i+1  
print("The sum of N natural numbers is:",sum)
print("End of program:")
   
Output:
Enter Number:10
The sum of N natural numbers is: 55
End of program:


टिप्पणी पोस्ट करा

0 टिप्पण्या