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 + " ");
}
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
Post a Comment