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]: n = 1000

In [2]: x = galois.ilog(n, 5); x
Out[2]: 4

In [3]: print(f"{5**x} <= {n} < {5**(x + 1)}")
625 <= 1000 < 3125