I'm trying to code the recursive function given in this answer (which unfortunately I can't post here due to the lack of LaTeX), in Python 3.0.
I'm new to coding and this is my attempt:-
def q(r,b,L):
pr = r/(r+b)
for k in range(1,L+1):
for j in range(1,k):
pr = pr * ((r-j)/(r+b-j)) * (b/r+b-j) * q(r-j,b-1,L)
f = pr + ((b/(r+b)) * q(r,b-1,L))
return f
But this is giving me a "division by zero" error for q(3,0,2). Could anyone help me with the code?