what result do you expect instead?
1. func(12) is not less than 5 so | return 2*func(12 - 5)+7
-> return 2*func(7)+7
2. func(7) is not less than 5 so | return 2*func(7 - 5)+7
-> return 2*func(2)+7
3. func(2) is less than 5 so | return 3*2
= 6
back to 2: return 2*(3*2)+7
-> 2*6+7
back to 1: return 2*(2*6+7)+7
-> 2*19+7
so: func(12) is the same as:
2*(2*(3*2)+7)+7 -> 2*(2*6+7)+7 -> 2*19+7 -> 45
Last edited on
You may also use a debugger to step trough your code, instead of dirtying it.
thanks all..I was not getting the return part..I was thinking it like this
2*func(12-5)+7 --> 2*7+7 this is wrong I see now..