// Class countdown will countdown from any positive number down to zero public class Countdown { public static void main(String[] args) { countdown(5); } // recursion: a method calling itself // Think about what happens when n is negative? // How should we address this case? public static void countdown(int n) { if(n == 0) { // base case // the problem is so small we just do it System.out.println("0!"); } else { // recursive case // - doing a little bit of the work System.out.print(n + " "); // - solving a smaller problem by recurring countdown(n - 1); } } public static void countdownFrom3() { System.out.print("3 "); countdownFrom2(); } public static void countdownFrom2() { System.out.print("2 "); countdownFrom1(); } public static void countdownFrom1() { System.out.print("1 "); countdownFrom0(); } public static void countdownFrom0() { System.out.println("0!"); } }