I have an exercise where I should count the ways of climbing a ladder with n amount of steps, with the following restriction: You can only go up by 1, 3 or 5 steps.
I readed that I should use Fibonacci recursion. So I adapted that restriction to the examples of 1, 2 and 3 steps rules that I could find.
(define (climb n)
(cond [(<= n 0) 0]
[(<= n 2) 1]
[(= n 3) 2]
[(> n 1) (+ (climb (- n 1)) (climb (- n 3)) (climb (- n 5)))]
)
)
But this don't work, for example: with (climb 5) the output is 4 and should be 5:
(1 1 1 1 1), (1 3), (3 1), (3 1 1), (1 3 1), (1 1 3), (5). The 5 ways of climbing the ladder.