CoCoA:PowerMod

From ApCoCoAWiki

PowerMod

compute a modular power efficiently

Description

This function calculates efficiently an integer power modulo a given

modulus. Thus PowerMod(A,B,M) is equal to Mod(A^B, M), but the former

is computed faster. B must be non-negative.

Example

  PowerMod(12345,41041,41041); -- 41041 is a Carmichael number
12345
-------------------------------
  PowerMod(123456789,987654321,32003); -- cannot compute 123456789^987654321 directly
2332
-------------------------------

Syntax

PowerMod(A:INT,B:INT,M:INT):INT

   <type>int</type>