In Python:
def g(n):
if n <=3:
return n
return g(n-1) + 2 * g(n-2) + 3 * g(n-3)
I understand what this function is doing, but I can’t seem to get how to make it iterative. Help, please. If possible, please include an explanation so that I could fully understand the problem.
1 Answer