Climbing stairs

You climb a staircase of n steps taking 1 or 2 steps at a time. Write ways(n) that returns how many distinct sequences of steps reach the top. ways(0) is 1 (do nothing).

ways(1)  ->  1
ways(2)  ->  2      (1+1, 2)
ways(3)  ->  3      (1+1+1, 1+2, 2+1)
ways(4)  ->  5

The point is to practise the three DP questions: the subproblem is ways(k), the recurrence is ways(k - 1) + ways(k - 2), and the bases are ways(0) = ways(1) = 1.

def ways(n):
    ...