>>> def lf(H, w): N = 2 while (math.log(w, N) != math.log(H, N+1)): N +=1 return(N) >>> lf(216, 125) 5 >>> lf(5764801, 1679616) 6