Finding sum of digits of a number until sum becomes single digit

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))

18 views

Recent Posts

See All

Lists | HACKER RANK

Asked: Rahul Kumar Ranjan |Category: Python n=int(input()) l=[] for i in range (n): x=input().split(" ") com=x[0] if com=="insert": l.insert(int(x[1]),int(x[2])) elif com=="print": print(l) elif com==

"Believe you can and you're halfway there"