Consider this:
public static void printFirstHalf(int m, int n){
if(m>n){
return;
}
// print asterix
for(int i=1; i<=m; i++){
System.out.print("*");
}
System.out.println();
// recurse
printFirstHalf(m+1,n);
}
Do you see where you went wrong with your other method now?
If you’re working with recursion for the first time, I understand that it can be difficult but there is no ‘magic’ with recursion. Work through the code step-by-step and understand what it does. In this case you weren’t actually printing the number of asterix needed. Keep at it.
0
solved Triangle Recursion Java [closed]