Where am i going wrong?

package Challenges;

import java.util.Scanner;

public class PascalTraingle {

public static void main(String[] args) {
	
Scanner scan = new Scanner(System.in);
int  n = scan.nextInt();

System.out.println("hekloji");

	
	int rows=1;
	int nst =1;


while(rows<=n)
{
	for(int cst=1;cst<=nst;cst++)
	{
		
		int var=fact(rows)/(fact(cst) * fact(rows-cst));
		System.out.print(var +"\t");
	}
	
	//preparation
	System.out.println();
	nst++;
	rows++;
}
	


}

public static int  fact(int n )
		{
			int factorial;
			
			
			for(factorial = 1; factorial < n;n--)
			{
				factorial = factorial*n;
			}
			return factorial;
			
		}

}

Hey @Nitya_Somani
problem in fact function
public static int fact(int n) {
int ans =1;
if(n==0) {
return 1;
}
for (int factorial = 1; factorial <=n; factorial++) {
ans*=factorial;
}
return ans;
}
correct code :
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
//System.out.println(“hekloji”);
//System.out.println(fact(5));
int rows = 1;
int nst = 1;
while (rows <= n) {
for (int cst = 0; cst < nst; cst++) {
int var = fact(rows-1) / ((fact(cst) * fact(rows-1 - cst)));
System.out.print(var + “\t”);
}
// preparation
System.out.println();
nst++;
rows++;
}
}

public static int fact(int n) {
	int ans =1;
	if(n==0) {
		return 1;
	}
	for (int factorial = 1; factorial <=n; factorial++) {
		ans*=factorial;
	}
	return ans;
}

}

fact(rows-1) / ((fact(cst) * fact(rows-1 - cst))) .
why you have taken rows -1 instead of rows ?

Question why you have taken rows -1 instead of rows ?
Answer :
row no 3
1 2 1 // 2c0 2c1 2c2