What is a prime number?
A prime number is a whole number greater than 1 whose only factors are 1 and itself. 7 is prime because nothing but 1 and 7 divides it evenly. 12 is not prime, because 2, 3, 4 and 6 also divide it; a whole number above 1 that is not prime is called composite.
- 0 and 1 are not prime. They are neither prime nor composite.
- 2 is the only even prime. Every larger even number is divisible by 2.
- Every whole number above 1 is prime or a product of primes, in exactly one way apart from order. That product is its prime factorization.
How to check if a number is prime
The method you learn in class is trial division: divide by each prime in turn and see whether any of them goes in evenly. You only need to go up to the square root. If a number had a factor bigger than its square root, the matching factor in the pair would be smaller than the square root, and you would already have found it.
Is 91 prime?
√91 ≈ 9.54, so try 2, 3, 5, 7. 91 ÷ 7 = 13, so 91 is not prime.
Is 89 prime?
√89 ≈ 9.43, so try 2, 3, 5, 7. None divides 89 evenly, so 89 is prime.
Quick rules rule out most numbers before you divide: an even number above 2 is divisible by 2, a number whose digits add up to a multiple of 3 is divisible by 3, and a number ending in 0 or 5 (other than 5) is divisible by 5.
How this prime number checker works
Every calculation runs in your browser with exact whole-number arithmetic, so even 20-digit numbers are never rounded.
- Below 2^32 (about 4.3 billion), the checker uses trial division, exactly as above, trying every possible divisor up to the square root.
- From 2^32 up to 2^64 − 1, trying every divisor would take too long, so it uses the Miller-Rabin test. In plain terms, the test picks a base such as 2 and raises it to powers built from the number minus 1, working with remainders. A prime always behaves in a predictable way under this test; most composite numbers break the pattern straight away. Run with a single base the test can be fooled, but mathematicians have checked that no composite number below 2^64 passes it for all twelve bases 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 and 37. So for this range the answer is proven, not just likely.
- Above 2^64 − 1 (18,446,744,073,709,551,615), the checker does not give an answer rather than risk a wrong one.
- Factors come from trial division by small primes and then Pollard's rho method, a fast way to split large numbers. It has a fixed work limit so the page never freezes. If a number is too large to factor within that limit, the checker still tells you it is not prime and says which part it could not split.
Prime factorization
The prime factorization writes a number as a product of primes. Divide by the smallest prime that goes in, then repeat with what is left until you reach 1. For 360:
360 as a product of primes
360 = 23 × 32 × 5
The exponents tell you how many factors a number has: add 1 to each exponent and multiply. For 360 that is 4 × 3 × 2 = 24 factors.
Prime numbers from 1 to 100
There are 25 prime numbers up to 100.
| Range | Primes | Count |
|---|---|---|
| 1 to 10 | 2, 3, 5, 7 | 4 |
| 11 to 20 | 11, 13, 17, 19 | 4 |
| 21 to 30 | 23, 29 | 2 |
| 31 to 40 | 31, 37 | 2 |
| 41 to 50 | 41, 43, 47 | 3 |
| 51 to 60 | 53, 59 | 2 |
| 61 to 70 | 61, 67 | 2 |
| 71 to 80 | 71, 73, 79 | 3 |
| 81 to 90 | 83, 89 | 2 |
| 91 to 100 | 97 | 1 |
Working with data rather than single numbers? Try the mean, median and mode calculator or the standard deviation calculator. To see where a test score leaves your class grade, use the grade calculator.