### The Maxima on-line user's manual

Algebra Calculator

#### Power_mod

Function: power_mod (<a>, <n>, <m>) Uses a modular algorithm to compute `a^n mod m` where <a> and <n> are integers and <m> is a positive integer. If <n> is negative, `inv_mod` is used to find the modular inverse.

```          (%i1) power_mod(3, 15, 5);
(%o1)                          2
(%i2) mod(3^15,5);
(%o2)                          2
(%i3) power_mod(2, -1, 5);
(%o3)                          3
(%i4) inv_mod(2,5);
(%o4)                          3```

```(%o1)                                true
(%i2) ```

### Related Examples

##### mod-power_mod

power_mod(power_mod(1...

Calculate

##### mod-power_mod

power_mod(1865, 280, ...

power_mod(1865, 281, ...

power_mod(1865, 282, ...

Calculate

##### mod-power_mod

power_mod(126,7,1643);

Calculate

##### mod-power_mod

power_mod(1237, -1, 1...

Calculate

##### mod-power_mod

power_mod(140, 140, 2...

power_mod(140, 141, 2...

power_mod(140, 142, 2...

Calculate

p:19;

g:3;

a:5;

Calculate

##### mod-power_mod-totient

x:power_mod(11,totien...

mod(22,15);

Calculate

##### mod-power_mod

power_mod(982346578,4...

power_mod(355995882,3...

Calculate

##### mod-power_mod

/*Signature message 2...

b = power_mod(4117902...

/*décrytage*/c = powe...

Calculate

##### mod-power_mod

power_mod(75,-1,38);

Calculate