61. Pascal’s triangle

EasyProgramFree10 points

Each row of Pascal’s triangle starts and ends with 1, and every other entry is the sum of the two entries above it. Write pascal n, the first n rows, from [1] downwards.

Examples

  1. Input: pascal 1Output: [[1]]
  2. Input: pascal 5Output: [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1]]

Submitting also runs 5 hidden tests.

Constraints

  • 0 ≤ n ≤ 30. pascal 0 is the empty list.
Solution.lean
Loading editor…

Run checks your code against the examples and your custom inputs and records nothing. Submit also runs the hidden tests, confirms the axioms your proof uses and records the result. Each uses one compiler check.

ReadyLn 1, Col 1Lean 4
Draft saved in this browser