galois.iroot

class galois.iroot(n, k)

Finds the integer \(k\)-th root \(x\) of \(n\), such that \(x^k \le n\).

Parameters
  • n (int) – A positive integer.

  • k (int) – The root \(k\), must be at least 2.

Returns

The integer \(k\)-th root \(x\) of \(n\), such that \(x^k \le n\)

Return type

int

Examples

In [1]: galois.iroot(27**5 - 1, 5)
Out[1]: 26

In [2]: galois.iroot(27**5, 5)
Out[2]: 27

In [3]: galois.iroot(27**5 + 1, 5)
Out[3]: 27