Run time error in fibonacci patten question(Pattern 4)

I am getting correct for two test cases, but i am getting a runerror for the third test case.
import java.util.*;
public class fibonaccipattern {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n;
n=sc.nextInt();
if(n<100 && n>0) {
int fibn;
int ans=0;
for(int i=n;i>=1;i–) {
ans+=i;
}
fibn=ans;
int [] arr= new int[fibn];
arr[0]=0;
arr[1]=1;

	for(int i=2;i<arr.length;i++) { //to find the fibonacci sequence and store in the array
		arr[i]=arr[i-1]+arr[i-2];
	}
	
	
	int row=1;
	int nst=1;
	int k=0;
	while(row<=n) {
		for(int cst=1;cst<=nst;cst++) {
			System.out.print(arr[k]+"\t");
			k++;
		}
		row=row+1;
		nst++;
		
		System.out.print("\n");
			
	}
	
	
	
	
	
	
}
	else {
		
	}

}
}

Hi Ashish

Your code doesn’t work for the case when input value is 1.

Oh , ok I got it.
Thanks for the help.

Hi Ashish

I am marking your doubt as resolved. If you face any more issues, feel free to reopen the thread.