Write a python function to find the sum of digits in a number until one digit (no more than one digit)


Topic: Write a python function to find the sum of digits in a number until one digit (no more than one digit)

Solution

 def digSum(n): 
    sum = 0
    while(n > 0 or sum > 9): 
      
        if(n == 0): 
            n = sum
            sum = 0         
        sum += n % 10
        n = int(n/10)    
    return sum
 



List all Python Programs