powmod

Fast power modulus calculation for BigInt operands.

pure nothrow @safe
powmod

Parameters

base BigInt

the BigInt is basic operands.

exponent BigInt

the BigInt is power exponent of base.

modulus BigInt

the BigInt is modules to be modular of base ^ exponent.

Return Value

Type: BigInt

The power modulus value of (base ^ exponent) % modulus.

Examples

for powmod

BigInt base = BigInt("123456789012345678901234567890");
BigInt exponent = BigInt("1234567890123456789012345678901234567");
BigInt modulus = BigInt("1234567");

BigInt result = powmod(base, exponent, modulus);
assert(result == 359079);

Meta