Last active
August 29, 2015 14:01
-
-
Save SeanTRobinson/c0e9b542b3efb47cd1f4 to your computer and use it in GitHub Desktop.
Generates a Pascal Triangle in an array structure.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static int[, ] createTriangle(int size) | |
{ | |
int[,] triangle = new int[size,size]; | |
for (int i = 0; i < size; i++) | |
{ | |
triangle[i, 0] = 1; | |
for (int j = 1; j < i; j++) | |
{ | |
triangle[i, j] = triangle[i-1, j-1] + triangle[i-1, j]; | |
} | |
triangle[i, i] = 1; | |
} | |
return triangle; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment