isprime {gmp} | R Documentation |
Determine whether the number is prime or not. 2: number is prime, 1, number is probably prime (without beeing certain), 0 number is composite.
isprime(n, reps = 40)
n |
Integer number, to be tested |
reps |
Integer, number of repeats |
This function does some trial divisions, then some Miller-Rabin probabilisticprimary tests. reps controls how many such tests are done, 5 to 10 is a resonable number. More will reduce the chances of a composite being returned as "probably prime".
0 |
Number is not prime |
1 |
Number is probably prime |
2 |
Number is prime |
Antoine Lucas
Gnu MP Library see http://swox.com/gmp
isprime(210) isprime(71) # All primes numbers from 1 to 100 t <-isprime(1:100) (1:100)[t>0]