6. Climbing stairs

EasyProgramFree10 points

You climb a staircase of n steps, taking one or two steps at a time. Write climbStairs n, the number of different sequences of moves that reach the top.

There is one way to climb zero steps: do nothing. The hidden tests go up to 50 steps, and each check stops after about twelve seconds, so a solution that recomputes the same values over and over will run out of time.

Examples

  1. InputclimbStairs 2Output2
  2. InputclimbStairs 3Output3
  3. InputclimbStairs 5Output8

Submitting also runs 6 hidden tests.

Constraints

  • climbStairs 0 = 1 and climbStairs 1 = 1.
  • Hidden tests use n up to 50.
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