pow

Computes x to the power y modulo z.

H
pow
(
I
G
H
)
(
in auto ref I x
,
in auto ref G y
,
in auto ref H z
)

Parameters

I

Base type.

G

Exponent type.

H

Divisor type:

x I

Base.

y G

Exponent.

z H

Divisor.

Return Value

Type: H

Reminder of the division of x to the power y by z.

Precondition: z > 0

Examples

assert(pow(3, 5, 7) == 5);
assert(pow(2, 2, 1) == 0);
assert(pow(3, 3, 3) == 0);
assert(pow(7, 4, 2) == 1);
assert(pow(53, 0, 2) == 1);
assert(pow(53, 1, 3) == 2);
assert(pow(53, 2, 5) == 4);
assert(pow(0, 0, 5) == 1);
assert(pow(0, 5, 5) == 0);

Meta