Primality by trial division: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 675: | Line 675: | ||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |
||
<lang>trial(n)={ |
<lang parigp>trial(n)={ |
||
if(n |
if(n < 4, return(n > 1)); /* Handle negatives */ |
||
forprime(p=2,sqrt(n), |
|||
forprime(p=3,sqrt(n), |
|||
if(n%p == 0, return(0)) |
if(n%p == 0, return(0)) |
||
); |
); |