Apr-04-2017, 08:52 PM
def f(n): if n < 5: return n + 1 return (f(n // 2) , f(n // 3) )f(100) is leading to an output of
(((((4, 3), 5), (5, 3)), ((5, 3), (3, 2))), (((5, 3), (3, 2)), ((3, 2), 4)))
I broke down the recursions like this:
f(50), f(33)
f(25), f(11)
f(12), f(3)
f(6), 4 #recursion stops
f(3), 4
4, 4
So I expected an outcome of (4,4)
However, I have no idea why I'm getting an output of
((((4, 3), 5), (5, 3)), ((5, 3), (3, 2))), (((5, 3), (3, 2)), ((3, 2), 4)))
Thank you.