Skip to content

Instantly share code, notes, and snippets.

@SeanTRobinson
Last active August 29, 2015 14:01
Show Gist options
  • Save SeanTRobinson/c0e9b542b3efb47cd1f4 to your computer and use it in GitHub Desktop.
Save SeanTRobinson/c0e9b542b3efb47cd1f4 to your computer and use it in GitHub Desktop.
Generates a Pascal Triangle in an array structure.
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