galois.pow

galois.pow(base, exponent, modulus)

Efficiently exponentiates an integer \(a^k\ \textrm{mod}\ m\).

The algorithm is more efficient than exponentiating first and then reducing modulo \(m\).

Note

This function is an alias of pow() in the standard library.

Parameters
  • base (int) – The integer base \(a\).

  • exponent (int) – The integer exponent \(k\).

  • modulus (int) – The integer modulus \(m\).

Returns

The modular exponentiation \(a^k\ \textrm{mod}\ m\).

Return type

int

Examples

In [1]: galois.pow(3, 5, 7)
Out[1]: 5

In [2]: (3**5) % 7
Out[2]: 5