Recursive sum of digits of a number formed by repeated appends | Return single digit sum of a number ; Returns recursive sum of digits of a number formed by repeating a number X number of times until sum become single digit . ; Driver Code
def digSum ( n ) : NEW_LINE INDENT if n == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT return ( n % 9 == 0 ) and 9 or ( n % 9 ) NEW_LINE DEDENT def repeatedNumberSum ( n , x ) : NEW_LINE INDENT sum = x * digSum ( n ) NEW_LINE return digSum ( sum ) NEW_LINE DEDENT n = 24 ; x = 3 NEW_LINE print ( repeatedNumberSum ( n , x ) ) NEW_LINE