/**
 * A program that uses a recursive method to count down.
 *
 * @author Mark Young (A00000000)
 */
public class CountDown {

    public static void main(String[] args) {
        System.out.println("\n"
                + "Counting Down\n"
                + "-------------");
        for (int i = 0; i <= 20; i += 5) {
            System.out.print("\nCounting down from " + i + ": ");
            countDownFrom(i);
        }
        System.out.print("\n\n");
    }

    /**
     * Print the numbers from n down to 1 on a single line.
     * (Uses recursion.)
     *
     * @pre  n >= 0
     * @post the numbers from n down to 1 have been printed on one line.
     *
     * @param n the number to count down from
     */
    public static void countDownFrom(int n) {
        if (n > 0) {
            // print out the biggest number...
            System.out.print(n + " ");
            // ... then count down from the next smallest number
            countDownFrom(n - 1);
        }
    }

}
