I need to create a program that creates a Pascal's Triangle based on a given n value, and place it into a 2D Array, and print it to the screen. I've been having a little trouble with my methods. For example, if n = 5 and k = 3, then the output should be like:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
PascalArray test = new PascalArray();
test.pascalNonRecursive(5); //GIVES ME 1121331464 as output
System.out.print(test.pascalRecursive(4, 2); //GIVES ME 6 as output
How can I fix (and refine) my code? I obviously need a lot of help, and I will really appreciate anything you give me. Thanks a lot!