Newton's method works great with integers; here we calculate the largest number s for which s k does not exceed n, assuming that both k and n are positive:
function iroot(k, n)
k1 := k - 1
s := n + 1
u := n
while u < s
s := u
u := ((u * k1) + n // (u ** k1)) // k
return s
, iroot(4, 624) 4 iroot(4, 625) 5. :
function perfectPower(k, n)
return (k ** iroot(k, n)) == n
, perfectPower(2, 625) perfectPower(4, 625) , perfectPower(3, 625) .
Java BigInteger.