// CSE 143, Winter 2011, Marty Stepp // This file contains two recursive methods that we "traced" in lecture. public class Mystery { public static void main(String[] args) { System.out.println(mystery(648)); System.out.println(mystery2(348)); } public static int mystery(int n) { if (n < 10) { return n; } else { int a = n / 10; int b = n % 10; return mystery(a + b); } } public static int mystery2(int n) { if (n < 10) { return (10 * n) + n; } else { int a = mystery2(n / 10); int b = mystery2(n % 10); return (100 * a) + b; } } }