# Thread: A Little Help Regarding Digital Root

1. ## A Little Help Regarding Digital Root

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:

Code:
```#include<stdio.h>
int rem=0;
{
int newnum;
rem = rem+(in%10);
newnum=in/10;

if(newnum==0)
{
return rem;
}
else
}
int main()
{
int no;
printf ("Enter the number: \n");
scanf ("%d", &no);
int ans=0;
return 0;
}```
How can I change it into a code that gives me the root till a single digit?

Thanks.

2. It's be much easier if you just computed in%9

3. Code:
```#include<stdio.h>
int rem=0;
{
int newnum;
rem = rem+(in%10);
newnum=in/10;

if(newnum==0)
{
if (rem > 9) { // Added
return rem;
}
else