Due: Monday, June 16
Goal: Learn about recursion
Given a non-negative int n, complete the sumDigits method so that it returns the sum of its digits recursively (no loops). Note that mod (%) by 10 yields the rightmost digit (126 % 10 is 6) while divide (/) by 10 removes the rightmost digit (126 / 10 is 12).
For example:
public static int sumDigits(int n)
{
// Write code in here that recursively sums the digits in n
}
It will probably be helpful to write the base/termination case first then focus on how to use % and / to recursively sum the digits of everything except the rightmost digit.