6.34.10 Calcul de an mod p ou de A(x)n mod¶(x),p:
powmod powermod
-
Pour calculer dans [0;p−1]
an mod p on utilise la commande powmod
ou powermod avec comme argument a,n,p.
On tape :
powmod(5,21,13)
On obtient :
5
On tape :
powmod(5,21,8)
On obtient :
5
- Pour calculer A(x)n mod¶(x),p avec en réponse un polynôme
à coefficients dans ℤ (qui seront des restes symétriques de division par p), on
utilise la commande powmod
ou powermod avec comme argument A(x),n,p,P(x).
On tape :
powmod(x+1,17,5,x^
4+x+1)
On obtient :
-x^
3-x^
2
On a en effet :
rem((x+1)^
17,x^
4+x+1)
qui renvoie :
29144*x^
3+36519*x^
2+12270*x-4185
et
(29144*x^
3+36519*x^
2+12270*x-4185)% 5
qui renvoie :
(-1 % 5)*x^
3+(-1 % 5)*x^
2
et
((-1 % 5)*x^
3+(-1 % 5)*x^
2)% 0
qui renvoie :
-x^
3-x^
2
Remarque (cf section 6.34.9)
Si on peut calculer une puissance dans ℤ/pℤ on tape par exemple :
:
(5% 13)^
21)
On obtient :
5% 13
On tape :
(5% 8)^
21)
On obtient :
-3% 8