A cat accidentally falls down a hole with sloping but rough sides. It can climb out of the hole of height h metres, but for every m metres it jumps, it falls back n metres where m is always bigger than n. It can only do one jump attempt per day and it is assumed that there is a small water source available to sustain it along the way.:) That said, how many days does it require to escape the hole?
NB: the cat must be clear of the hole or above it to escape so reaching exactly level with the hole opening it will still fall back down n metres.
HINT: once the cat is clear of the hole with its last jump it will not fall back into the hole.
EX: >> h = 20; m = 5; n = 3;
ans = 9
MATLAB and Simulink resources for Arduino, LEGO, and Raspberry PiLearn more
Opportunities for recent engineering grads.Apply Today
New to MATLAB?Learn MATLAB today!
Play games and win prizes!Learn more