def G(p): n = 0 while not Bernoulli(p): n += 1 return n