Let there be $n$ floors ($n<30$) in some building. In order to arrive to the $n$-th floor we can climb one or two floors each time. On floor $20$ there's an elevator. If we arrive to the $20$-th floor we must take the elevator to the $n$-th floor. Design recursive algorithm to determine in how many ways it is possible to climb to the $n$-th floor? (if $29<n$ or $n<20$ then there're $0$ ways).
For example:
the person can climb to the $19$-th floor, climbing one or two floors at a time, then climb two floors to floor $21$ and then continue climbing one or two floors at a time until reaching $n$-th floor.
the person can climb $20$ floors than the person must take the elevator to the $n$-th floor
Without the elevator constraint the problem may be solved using the following recurrence: $$ f(0) = 1\\f(-1)=0\\ f(n)=f(n-1)+f(n-2) $$ Through trial and error process I think to solve the problem with elevator constraint we can design formula $f'(n)$: $$ f'(n)=f(n)-f(20)-f(19)-f(18) $$ Intuitively this makes sense: we subtract $f(20)$ from $f'(n)$ because all climb paths after arriving to floor $20$ are illegal as we must take the elevator. But why do we need to subtract $f(19)$ and $f(18)$? Because they can lead to floor $20$?
I'm not sure if $f'(n)$ is correct and if it is why we need to subtract $f(19)$ and $f(18)$.