[Java] Printing numbers in ascending order recursively.
I'm having trouble understanding why this loops after printing 1.
public class test {
public static void main(String[] args) {
program1(10);
}
public static void program1(int n){
if (n > 1){
program1(n - 1);
}
System.out.print(n+" ");
}
}
Posted Mar 7, 2016, 2:24 AM UTC
27