Add Digits



Problem to sum the digits and continue the same process until length become one.



Example-1:


Input    : num = 1234
Output   : 1
Explain  : 1 + 2 + 3 + 4 = 10
           1 + 0 = 1.  


Example-2:


Input    : num = 12345
Output   : 6
Explain  : 1 + 2 + 3 + 4 + 5 = 15 
           1 + 5 = 6.







Solution





num = 1234

if(num % 9 == 0 and num != 0):

    print(9)

else:

    print(num % 9)



Output



1