avatar Bite 284. Pascal triangle

A Pascal triangle is a triangular array of integers constructed with the following characteristics:

1. The first row consists of the number 1.

2. For each subsequent row, each element is the sum of the numbers directly above it, on either side.

Here is an example of the first 5 rows:

    1

   1 1

  1 2 1

 1 3 3 1

1 4 6 4 1

Exercise

Given an input N, return the Nth row of Pascal's triangle in a list.

Example for N = 5

>>> pascal(N) 

 [1, 4, 6, 4, 1]

 

Login and get coding
go back Intermediate level
Bitecoin 3X

106 out of 106 users completed this Bite.
Will you be the 107th person to crack this Bite?
Resolution time: ~37 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 6.33 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help