I wrote a pascal's triangle program with an imbedded 'for' loop and a Factorial class that computes the factorial of a number. When it gets to the third line of the triangle the problems arise. If anyone could help I would greatly appreciate it. Here is my code:

// -------------------------------------------------------------------- // This program is intended to make Pascal's triangle. // -------------------------------------------------------------------- package PascalTriangle; public class PascTri { public static void main (String[] args){ Factorial factorial = new Factorial(); int n, k, subtract; // The number of rows is set to five for now int rows = 5; long term1; long term2; long term3; long term4; long endTerm; // 'n' represents the line in Pascal's triangle // 'k' represents the term in a line in Pascal's triangle for(n = 0; n <= rows-1; n++) { for(k = 0; k <= n; k++ ) { subtract = n-k; term1 = factorial.Factorial(n); term2 = factorial.Factorial(k); term3 = factorial.Factorial(subtract); term4 = term2 * term3; endTerm = term1/term4; System.out.print(endTerm + " "); // I typed this line simply to help troubleshoot System.out.print("Term1: " + term1 + " Term2: " + term2 + " Term3: " + term3 + " | "); } System.out.println(); } } } // ********************************************** // Factorial Class // ********************************************** class Factorial { private long hideFact; long i; long finFact = 1; long Factorial(long factNum) { hideFact = factNum; if (hideFact == 1) finFact = 1; else if (hideFact == 0) finFact = 1; else for(i = hideFact; i >= 1; i--) { finFact *= i; } return finFact; } }