### 7.1.14 Testing primality

The is_prime, isprime and isPrime commands are tests for primality.

- is_prime takes n, an integer.
- is_prime(n) returns 1 if n is prime and 0 if n is not prime.

isprime and isPrime are the same as is_prime, except they return true or false.

#### Examples

is_prime(100003)

1 |  |  |  |  |  |  |  |  |  |

isprime(100003)

true |  |  |  |  |  |  |  |  |  |

is_prime(98569898989987)

1 |  |  |  |  |  |  |  |  |  |

is_prime(14)

0 |  |  |  |  |  |  |  |  |  |

isprime(14)

false |  |  |  |  |  |  |  |  |  |

Use the command pari("isprime",n,1) (see Section 7.2.10) to get a primality certificate (see the documentation PARI/GP with the menu Help▸Manuals▸PARI-GP) and pari("isprime",n,2) to use the APRCL test.

#### Examples

isprime(9856989898997789789)

true |  |  |  |  |  |  |  |  |  |

pari("isprime",9856989898997789789,1)

⎡
⎢
⎢
⎢
⎣

2 | 2 | 1
19 | 2 | 1
941 | 2 | 1
1873 | 2 | 1

⎤
⎥
⎥
⎥
⎦

which are the coefficients giving the proof of primality by the p−1 Selfridge-Pocklington-Lehmer test.