Exercise 1: Pascal Triangle

In this exercise, you will be required to make a function which displays the Pascal Triangle for any size given.

We'll cover the following

Problem Statement

This is a C# exercise about using a two-dimensional array.

Write a C# program to display a table that represents a Pascal triangle of any size.

Pascal triangle

In Pascal triangle,

  • first and the second rows are set to 1.
  • Each element of the triangle (from the third row downward) is the sum of the element directly above it and the element to the left of the element directly above it.

Consider the following example of a pascal triangle:

    1
   1 1
  1 2 1
 1 3 3 1
1 4 6 4 1

Get hands-on with 1200+ tech skills courses.