public class Stutter { public static void main(String[] args) { System.out.println(stutter(-348)); } // Returns the value obtained by duplicating each digit of n. The stutter of 0 is 0. // Example: stutter(348) => 334488 public static int stutter(int n) { if (n < 0 ) { // recursive case 1 return -stutter(-n); } else if (n < 10) { // base case return 11 * n; } else { // recursive case 2 return 100 * stutter(n / 10) + stutter(n % 10); } } /* Below is a trace of the call stutter(-348): stutter(-348) is < 0, so execute first branch compute stutter(-n), which is stutter(348) | not < 0, not < 10, so execute third branch | compute stutter(34) | | not < 0, not < 10, so execute third branch | | compute stutter(3) | | | not < 0, but is < 10, so execute second branch | | | return n * 11 (33) | | compute stutter(4) | | | not < 0, but is < 10, so execute second branch | | | return n * 11 (44) | | return first * 100 + second (33 * 100 + 44 = 3344) | compute stutter(8) | | not < 0, but is < 10, so execute second branch | | return n * 11 (88) | return first * 100 + second (3344 * 100 + 88 = 334488) return the negation of that result (-334488) */ }