Is It Prime? A Fast Way to Test Any Number
Learn the quick checks and the square-root shortcut for deciding whether a number is prime, with worked examples like 143, 197 and 1001.
A prime number can only be divided evenly by 1 and by itself. 7, 23 and 101 are prime; 9, 21 and 100 are not. Testing a small number is easy, but how do you check something like 197 without trying every number below it? You need far fewer tests than you might think.
First, the free checks
Before dividing anything, glance at the digits:
- Ends in 0, 2, 4, 6 or 8: it is even, so it is not prime (except 2 itself).
- Ends in 5 or 0: it divides by 5.
- Digits add up to a multiple of 3: it divides by 3. 117 has digit sum 9, so 117 = 3 × 39.
These three checks clear most numbers in seconds.
The square-root shortcut
If a number n can be split into two factors, one of them must be no bigger than √n. So you only need to try the primes up to √n. If none of them divides n, it is prime.
Example: 197
√197 is just over 14, so the primes to try are 2, 3, 5, 7, 11 and 13. 197 is odd, its digits add to 17, and it does not end in 5. Then 197 ÷ 7, ÷ 11 and ÷ 13 all leave remainders. Nothing divides it, so 197 is prime.
Example: 143
√143 is about 12, so try primes up to 11. It is odd, the digit sum is 8, and 7 does not divide it. But 143 ÷ 11 = 13 exactly. So 143 = 11 × 13, and it is not prime.
Numbers that look prime but are not
Some composites fool people because they are odd and avoid the easy checks: 57 = 3 × 19, 91 = 7 × 13, 133 = 7 × 19 and 1001 = 7 × 11 × 13. The 7 test catches most of them.
Splitting a number into primes
When a number is not prime, keep dividing by the smallest prime that works. 1001 ÷ 7 = 143, then 143 ÷ 11 = 13. So 1001 = 7 × 11 × 13. Every whole number above 1 has exactly one such prime breakdown.
A quick list
The primes between 100 and 150 are 101, 103, 107, 109, 113, 127, 131, 137, 139 and 149.
Tip Every prime above 3 sits right next to a multiple of 6, such as 29 and 31 beside 30. It is a handy filter, but not a proof: 35 sits next to 36 and is 5 × 7.
Try it yourself: Prime Number CheckerTest if a number is prime and get its prime factors, all its divisors and the nearest primesOpen →Common questions
Why is 2 the only even prime?
Every other even number can be divided by 2, which gives it a third divisor.
Is 0 prime?
No. Primes must be greater than 1.
How many primes are there?
Infinitely many. Euclid proved this more than 2,000 years ago.