galois.ilog

galois.ilog(n, b)

Computes \(x = \lfloor\textrm{log}_b(n)\rfloor\) such that \(b^x \le n < b^{x + 1}\).

Parameters
  • n (int) – A positive integer.

  • b (int) – The logarithm base \(b\).

Returns

The integer logarithm base \(b\) of \(n\).

Return type

int

Examples

In [1]: galois.ilog(27**5 - 1, 27)
Out[1]: 4

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

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