# Math Help - Stairs problem (recurrence)

1. ## Stairs problem (recurrence)

Consider a staircase with n stairs which one can clim by 2 stairs or by 3 stairs at each step. e.g. a staircase with n=9 stairs can be climbed in exactly 5 ways.
Write a recurrence relation for the number of ways to ascend this staircase.
I worked out the values for [Consider a staircase with n stairs which one can clim by 2 stairs or by 3 stairs at each step. e.g. a staircase with n=9 stairs can be climbed in exactly 5 ways.
Write a recurrence relation for the number of ways to ascend this staircase.

I worked out the values for $Q_{n}$ up to 9:
$Q_{0}= 0$
$Q_{1}= 0$
$Q_{2}= 1$
$Q_{3}= 1$
$Q_{4}= 1$
$Q_{5}= 2$
$Q_{6}= 2$
$Q_{7}= 3$
$Q_{8}= 4$
$Q_{9}= 5$

which gave me $Q(n) = Q(n-2) + Q(n-3)$ but I think this is wrong.

Please double-check my values for $Q_{n}$/help me solve this!

2. Originally Posted by DaRush19
Consider a staircase with n stairs which one can clim by 2 stairs or by 3 stairs at each step. e.g. a staircase with n=9 stairs can be climbed in exactly 5 ways.
Write a recurrence relation for the number of ways to ascend this staircase.
I worked out the values for [Consider a staircase with n stairs which one can clim by 2 stairs or by 3 stairs at each step. e.g. a staircase with n=9 stairs can be climbed in exactly 5 ways.
Write a recurrence relation for the number of ways to ascend this staircase.

I worked out the values for $Q_{n}$ up to 9:
$Q_{0}= 0$
$Q_{1}= 0$
$Q_{2}= 1$
$Q_{3}= 1$
$Q_{4}= 1$
$Q_{5}= 2$
$Q_{6}= 2$
$Q_{7}= 3$
$Q_{8}= 4$
$Q_{9}= 5$

which gave me $Q(n) = Q(n-2) + Q(n-3)$ but I think this is wrong.

Please double-check my values for $Q_{n}$/help me solve this!
Your recurrence relation is correct!

Think about the last step, that takes one to the top of the staircase. It covers either the top two stairs or the top three stairs. So to climb a flight of n stairs, you either climb the first n–2 stairs, followed by a 2-stair step; or you climb the first n–3 stairs, followed by a 3-stair step. Think about the number of ways of doing that, and you'll see where the recurrence relation came from.