Please help me reach the right code through this code which i have written

package Recursion;

public class Recursion
{

public static void main(String[] args) {
	// TODO Auto-generated method stub
	pattern(5,4,4);

}

public static void pattern(int N,int row,int col) {
	
	if(row == 0 ) {
		return;
	}
	
	else if (col <= row) {
		System.out.println("*");
		
		if (col == 0) {
			pattern(N,row-1,col);
		}
		pattern(N,row,col-1);
	}
	else if(col > row) {
		System.out.println(" ");
		pattern(N,row,col-1);
	}
}

}

https://ide.codingblocks.com/s/203479 this is the link of my code

@himanshuep32,

The approach you are trying won’t work because we keeping the track of number of stars using row and col variables. If you want to print an inverted triangle then that approach is fine, but it will give errors.
Also the work done by recursion condition is not write which is why the code is giving infinite loop.

@sanchit.bansal06 is there any possibility that the doubt can be resolved over call ?

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.