CoCoA:PowerMod

From ApCoCoAWiki
Revision as of 10:02, 24 October 2007 by XMLBot (talk | contribs) (pushing XML rev. 1.46, again)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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>