← Back to challenges

Pascal's Triangle Rows

PythonHardmathnumbers

Instructions

Create a function that returns the nth row of Pascal's triangle:

Pascals triangle

Examples

pascal_row(0) ➞ [1]

pascal_row(1) ➞ [1, 1]

pascal_row(5) ➞ [1, 5, 10, 10, 5, 1]

pascal_row(10) ➞ [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1]

Notes

Input will include large numbers (the formula n choose k, or n!/(k!*(n-k)!) won't do).

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.