I have to build a method to add every digit of a string given in parameter and so till there are only 1 digit left, e.g. 1234 = (1+2+3+4) = 10 = (1+0) = 1.
At first, I thought a recursive call or a while loop should be fine. But Is there a smarter way? Using the modulo perhaps?
1234 % 9 = 1 That's seems to work... But no: 9%9 is not equal to 9 but it is to 0.
Is there a way to build this function without recursive/for/ while?
 
     
     
     
    