/**
 * 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.println("\nCounting down recursively from " + i + ": ");
            countDownFrom(i);
            System.out.println();
        }
        System.out.print("\n\n");
    }

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

}
