Print n numbers using recursion

The following is the java method to print n numbers using recursion :-


public static void print(int n) {

        if (n == 0)

            return;

        print(n - 1);

        System.out.print(n + " ");

}

Comments

Popular posts from this blog

Hackerrank Solution :- print-the-elements-of-a-linked-list

New KeyBoard (Hack The Interview V : Asia-Pacific)