Recursion Pattern

I think your logic is very sophisticated. We do not need column variable. The function can be called pattern(5,0).
What is your opinion ??

public static void pattern(int n, int row) {

	for(int x = 0; x <= row; ++x)
	{
		System.out.print("x");
	}
	System.out.println("");

	if( row == (n-1) )
		return;

	pattern(n, row+1);

}

Hey @connectrajanjain Yes your code is also correct. But the logic is same of both of you bcoz instead of using separate call for col + 1 you have given a for loop and the loop will do all the working of that call so instead of col + 1 recursive call you have used for loop.

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.