I recently saw this as an interview question and was completely stumped by it..
Calculate phi using numpy.random.uniform
I was thinking $$a + \frac{b}{a} = \frac{a}{b} $$
might be useful in that you could simply generate random numbers between 0 and 1 and assign to $A$. You can then generate a new number from 0 to 1 and keep it if it satisfied the equality. In the end you can just divide the means of the generated quanitities.