I am trying to write a recursive method to print an increment of a number of asterisks specified.
triangle(5) would print this:
*
**
***
****
*****
However, the code I wrote seems to do the opposite and I'm not sure how to reverse it although I tried and it gives me endless loop. Any ideas?
public static void triangle(int n){
if(n > 0){
System.out.println("");
for(int j = 0; j < n; j++)
System.out.print("*");
triangle(n-1);
}