high = 1
while high ** n <= x:
    high *= 2
low = high / 2
while low < high:
    mid = (low + high) // 2
if low < mid and mid ** n < x:
    low = mid
elif high > mid and mid ** n > x:
    high = mid
else:
    return mid
return mid + 1
How to compute the nth root of a very big integer