galois.pow

class 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 [606]: galois.pow(3, 5, 7)
Out[606]: 5

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