1
$\begingroup$

I need help with this recursion question:

help

  • 0
    Over 90% of all recursion homeworks are algorithms for Fibonacci numbers. 2010-12-13

2 Answers 2

7

Don't code it! Instead compute the first 4 or so values by hand and see if you understand what is going on. You don't even have to look at the numbers, you just need to see what you are doing when you evaluate the code. E.g. try to say in words what you do when you follow the code. Pretend that you are explaining the program to a friend: "so this thing first checks whether the second parameter is less than 100..."

If you don't see what you are doing, then do some more iterations (by hand) and look at the numbers, you will easily recognise them. If you don't recognise them, please leave a comment here, telling us what the numbers are.

But let me repeat: if you want to practice reading code, try to understand what you are doing, rather than guess a pattern from the numbers. Therefore, do not code it!

  • 1
    They used to give a first years' course where every single weekly exercise sheet come back to these numbers.2010-12-11
1

HINT $\ \ $ Show the sequence of Current values has form $\rm\ 1,\ 1,\ 2,\ \cdots\ a,\ b,\ a+b$