package recursion1;

/*
 * Given a non-negative int n, return 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).
 * 
 * sumDigits(126) -> 9
 * sumDigits(49) -> 13
 * sumDigits(12) -> 3
 */

public class SumDigitsTest {
	
	public static void main(String[] args) {
	    SumDigitsTest test = new SumDigitsTest();
	    System.out.println(test.sumDigits(126));
	    System.out.println(test.sumDigits(49));
	    System.out.println(test.sumDigits(12));
	}
	
	public int sumDigits(int n) {
	    if (n / 10 == 0) {
	        return n;
	    } else {
	        return (n % 10) + sumDigits(n / 10);
	    }
	}
}
@@ -269,16 +269,17 @@
 ts(126) 
+-
 -%3E 9%0A * 
@@ -292,16 +292,17 @@
 its(49) 
+-
 -%3E 13%0A *
@@ -316,16 +316,17 @@
 its(12) 
+-
 -%3E 3%0A */
@@ -733,8 +733,9 @@
   %7D%0A%09%7D%0A%7D
+%0A

Update SumDigitsTest.java