How to find integer nth roots?
One solution first brackets the answer between lo and hi by repeatedly multiplying hi by 2 until n is between lo and hi, then uses binary search to compute the exact answer: def iroot(k, n): hi = 1 while pow(hi, k) < n: hi *= 2 lo = hi // 2 while hi – lo … Read more