Is 91 prime? Many people say yes at first glance, because it is odd, does not end in 5 and is not in the times tables most of us learned. It is actually 7 × 13. Spotting primes is a mix of a few reliable rules and one big shortcut that saves most of the work.
This guide explains exactly what a prime number is, the tests you can do in your head, the square root rule that tells you when to stop, how to list all primes in a range with a sieve, and how computers check numbers with dozens of digits. Every example was confirmed with our checker.
What counts as a prime
A prime number is a whole number greater than 1 with exactly two divisors: 1 and itself. The first primes are 2, 3, 5, 7, 11, 13, 17, 19, 23 and 29.
A whole number greater than 1 that is not prime is composite: it can be written as a product of smaller whole numbers, such as 91 = 7 × 13.
Three edge cases catch people out:
- 1 is not prime. It has only one divisor. Excluding it keeps the rule that every number has exactly one prime factorisation.
- 0 is not prime. Every whole number divides 0.
- 2 is the only even prime. Every other even number is divisible by 2.
Quick divisibility tests
Before any real division, these checks eliminate most composites:
| Divisor | Test | Example |
|---|---|---|
| 2 | Last digit is even | 1,358 is divisible |
| 3 | Digit sum divisible by 3 | 51: 5 + 1 = 6, so 51 = 3 × 17 |
| 5 | Ends in 0 or 5 | 2,345 is divisible |
| 7 | Double the last digit, subtract from the rest | 91: 9 − 2 = 7, divisible |
| 11 | Alternating digit sum divisible by 11 | 2,728: 2 − 7 + 2 − 8 = −11, divisible |
The digit-sum test for 3 is the one to remember. Numbers such as 51, 57 and 87 look prime but are 3 × 17, 3 × 19 and 3 × 29.
The square root rule: when you can stop
To test whether n is prime, you only need to try dividing by primes up to √n.
The reason: if n = a × b and both a and b were bigger than √n, their product would be bigger than n. So any composite number has at least one factor no larger than its square root.
Example: is 97 prime? √97 ≈ 9.85, so try 2, 3, 5 and 7. None divides 97, so 97 is prime. Four checks are enough.
Example: is 221 prime? √221 ≈ 14.87, so try 2, 3, 5, 7, 11 and 13. The first five fail, but 221 ÷ 13 = 17 exactly. 221 = 13 × 17, composite.
This is called trial division. It is perfect by hand for numbers up to a few thousand and fast on a computer up to about 10¹².
Listing primes: the Sieve of Eratosthenes
To find every prime in a range, testing each number separately is wasteful. The Sieve of Eratosthenes works the other way around:
- Write the numbers from 2 to your limit.
- Circle 2 and cross out every multiple of 2.
- Move to the next number not crossed out (3), circle it and cross out its multiples.
- Repeat until you pass √limit. Everything still standing is prime.
For 1 to 100 you only sieve with 2, 3, 5 and 7, and 25 primes remain. Up to 1,000 there are 168.
Testing huge numbers
Trial division becomes hopeless for numbers with 20 or more digits. Computers use probabilistic tests instead, the best known being the Miller–Rabin test. It checks a mathematical property that every prime has, using a chosen "base". A composite number fails for most bases, so testing many bases gives overwhelming evidence.
Two refinements make it practical:
- For numbers below about 3.3 × 10²⁴, mathematicians have proven that a specific set of 13 bases is enough. For those numbers Miller–Rabin is a proof, not a guess.
- For larger numbers, passing many random bases leaves a chance of error so small it is ignored in practice, though it is not a formal proof.
Older shortcuts such as the Fermat test are fooled by special composites called Carmichael numbers. The smallest, 561 = 3 × 11 × 17, passes the Fermat test for every base that shares no factor with it. Miller–Rabin does not have this weakness.
How to use the Prime Number Checker
The Prime Number Checker has two tabs.
Check a number
- Type a whole number of up to 60 digits into Number to check, for example 221 or 1000000007.
- The result says Prime, Not prime or, for very large numbers above the proven range, Prime (probable).
- For composites you also get the Prime factorisation, the Smallest prime factor, the Number of divisors and a list of All divisors for smaller numbers.
- Every result shows the Previous prime and Next prime.
- The steps explain the test used: the square root bound and the dividing prime for numbers up to 10¹², or Miller–Rabin above that.
List primes in a range
- Enter From and To. The range can end as high as 10¹² and span up to 1,000,000 numbers.
- The result gives the count of primes and the smallest and largest. The full list appears below, and the copy button copies every prime even if the display is trimmed.
If you are working with factors more than primality, the Prime Factorization Calculator focuses on that job, and the GCF Calculator and LCM Calculator use factorisations to combine numbers.
Other ways to check
- Spreadsheets have no built-in prime test. You can build trial division with a formula, but it is clumsy beyond small numbers.
- Programming languages offer libraries: Python's
sympy.isprime(), for instance, uses a combination of strong tests. Writing your own trial division is a classic first exercise. - Printed prime tables are fine for small numbers but stop quickly.
Common mistakes
Calling 1 prime
It has only one divisor. By definition primes need exactly two.
Assuming odd numbers are probably prime
Most odd numbers are composite. Among the odd numbers from 51 to 99, the primes are only 53, 59, 61, 67, 71, 73, 79, 83, 89 and 97 — ten out of 25.
Checking past the square root
Once you pass √n without finding a divisor, stop. Further checks cannot find anything new.
Trusting a pattern
Formulas such as n² + n + 41 produce primes for n = 0 to 39 and then fail at n = 40. No simple formula generates only primes.
Frequently asked questions
Is 1 a prime number?
No. A prime must have exactly two different divisors, and 1 has only one. Treating 1 as prime would also break the uniqueness of prime factorisation.
What is the fastest way to check if a number is prime by hand?
Apply quick divisibility tests for 2, 3 and 5, then divide by the remaining primes up to the square root of the number. If none divides it, the number is prime.
How many prime numbers are there below 100?
There are 25: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89 and 97.
Is there a largest prime number?
No. Euclid proved there are infinitely many primes: multiply any finite list of primes together and add 1, and the result has a prime factor that is not on the list.
What does "probable prime" mean?
It means a number passed a strong probabilistic test such as Miller–Rabin many times. The chance that it is actually composite is astronomically small, but for very large numbers it is not a formal proof.