Answers for "python program to find sum of n numbers using while loop"

1

program to find sum till n natural numbers in python

#sum of natural number till n.
n=int(input('no. :'))
gross=0
no=0
while no < n:
    no+=1
    gross+=no
    print('no.', no ,'sum of n', gross)
print('no.',n,'total',gross)
Posted by: Guest on December-11-2021
1

python program to find sum of digits of a number using while loop

#  Write a Program to display sum of all digits of a given
#  Number N by user

n = int(input('Enter a number : '))
sum=0

while(n>0):
    rem = n%10
    sum = sum+rem
    n = n//10
print('reversed no. is : ',int(sum))
Posted by: Guest on October-27-2021

Code answers related to "python program to find sum of n numbers using while loop"

Python Answers by Framework

Browse Popular Code Answers by Language