powmod

Computes the value of a positive integer x, raised to the power n, modulo m.

Unqual!(Largest!(F, H))
powmod
(
F
G
H
)
(
F x
,
G n
,
H m
)

Parameters

x F

base

n G

exponent

m H

modulus

Return Value

Type: Unqual!(Largest!(F, H))

x to the power n, modulo m. The return type is the largest of x's and m's type.

The function requires that all values have unsigned types.

Examples

assert(powmod(1U, 10U, 3U) == 1);
assert(powmod(3U, 2U, 6U) == 3);
assert(powmod(5U, 5U, 15U) == 5);
assert(powmod(2U, 3U, 5U) == 3);
assert(powmod(2U, 4U, 5U) == 1);
assert(powmod(2U, 5U, 5U) == 2);

Meta