Okay, I did some research and game up with a solution to the initial question, which is shown below as digitSum(num). Now I need to write an additional function, digitalRoot(num) which will continue the process, for example:

digitsum takes input 444, and outputs 12

digitalRoot will continue and add the digits of 12 and output 3

My initial thought was to use a while loop and while num>10 (or more than one digit), it will repeat the process and output a single digit. However, I can't figure out how to do so. The function can only return num, but I need an additional variable to do all of the math.

I'm sure I'm overlooking something .. Any help would be appreciated.

Code:

public class Functions {
public static int digitSum(int num){
if (num<10)
return (num);
else
return ((num%10) + digitSum(num/10));
}
public static int digitalRoot(int num){
if (num<10)
return (num);
while (num>=10){
int temp = ((num%10) + digitalRoot(num/10));
}
return temp;
}
}