I want to find the greatest integer less than or equal to the kth root of n. I tried
int(n**(1/k))
But for n=125, k=3 this gives the wrong
def nth_root(n, k): x = n**(1./k) y = int(x) return y + 1 if y != x else y