Piccolo teorema di Fermat: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica
Riga 92:
[[vi:Định lý nhỏ Fermat]]
[[zh:费马小定理]]
 
== Implementazione | PARI-GP ==
LFT(n,nbasi=100,logprint=0) = local(M=0, i=0, ret=1);{
if( n <=1, error("You must insert a positive number > 1 ..."));
print(" ");
print("Little Fermat's Theorem ...");
print("Test on a number of base : ", nbasi);
ret=1;
/* We use prime number, a stronger condition than gcd(base, n) == 1
but this excludes Carmichael numbers (a-PR) and a-SPR */
forprime(i=1,nbasi,
if( i < n,
/* We use Mod(i,n)^(n-1) instead of Mod(i^(n-1),n) for the speed */
if( lift(Mod(i, n)^(n-1)) != 1,
ret=0;
if( logprint == 1,
print("Not prime for base : ", i);
);
break;
);
);
);
return(ret);}