I have the following recurrence relation H(n) = 2*H(n-1) + 1, H(1) = 1. If i were to make a recursive function in python how might this look? I have attempted with the following, but it does not seem to work
def rec_func(N, n=0, H=[])
if n == 1:
return [1] + H
else:
return rec_fun(N-1, n+1, H)
I might be totally off, but any hint would be appreciated. It is supposed to return a list of the elements [H(1), H(2),...H(N)]
note that the n=0, H=[]
in the constructor is obligatory. This is an excercise from my textbook "Numerical Analysis"