galois.pow

galois.pow(base, exp, mod)

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

The algorithm is more efficient than exponentiating first and then reducing modulo \(m\). This is the integer equivalent of galois.poly_pow().

Note

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

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

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

  • mod (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