Fibonacci Patterns

I am pasting my code below, please let me know for which test case it is failing, As I am unable to find it.

import java.util.*;
public class Main {
public static void main(String args[]) {

	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int row = 3;
	
	int a = 0;
	int b = 1;
	int c = a+b;
	System.out.println(a+"\t");

	if(n==1)
	System.out.println(b+"\t");

	if(n>=2)
	System.out.println(b+"\t"+c+"\t");

	while(row<=n){

			for(int cst = 1;cst<=row;cst++){
				a = b;
				b = c;
				c = a+b;
				System.out.print(c+"\t");	
			}

			System.out.println();
			row++;

	}

}

}

@alisaban10_b6a0dfdcbf5cfeff for n = 1 your code is printing :
0
1
but correct output is :
0

1 Like

Ok got it, thanks for guiding!

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.