Finding sum of digits of a number until sum becomes single digit
- Team ATC
- Nov 8, 2020
- 1 min read
Asked: Pushkar Tiwari |Category: Python
n=eval(input("Enter the value of n : "))
import math
def digSum( n):
sum = 0
while(n > 0 or sum > 9):
if(n == 0):
n = sum
sum = 0
sum += n % 10
n //= 10
return sum
print (digSum(n))
Comments