I found an interesting problem regarding the 'digital root' of a number. In it you add the digits of a number until you find a single digit. For example, digital root of 1032 would be 1+0+3+2=6 and digital root of 2354 would be 2+3+5+4=14=1+4=5.
I made a recersive code about it but I can't arrive at a single digit. It gives you the sum of all the digits of the number but not the sum till a single digit. Here's the code:
How can I change it into a code that gives me the root till a single digit?
int digit_adder(int in)
rem = rem+(in%10);
printf ("Enter the number: \n");
scanf ("%d", &no);
printf("\n%d\n\n",(ans = digit_adder(no)));