How to check if a number is prime
- Type a whole number up to 10,000,000,000,000 in Number.
- Read the answer. If it isn't prime, its prime factorization is shown underneath, with powers for repeated factors.
- Below that are the number of divisors and the closest primes below and above your number.
Quick divisibility checks
Before reaching for a calculator, these rules rule out most numbers:
| Divisible by | Rule | Example |
|---|---|---|
| 2 | Last digit is even | 1,358 |
| 3 | Digits add up to a multiple of 3 | 471: 4 + 7 + 1 = 12 |
| 5 | Ends in 0 or 5 | 2,045 |
| 9 | Digits add up to a multiple of 9 | 3,069: 3 + 0 + 6 + 9 = 18 |
| 11 | Alternating sum of digits is a multiple of 11 | 918,082: 9 − 1 + 8 − 0 + 8 − 2 = 22 |
2 is the only even prime, and every prime above 3 is one more or one less than a multiple of 6. That doesn’t make every such number prime (25 and 35 aren’t), but it means any prime candidate other than 2 and 3 has to pass that test first.
How the checker works
It uses trial division: it divides by 2 and then by odd numbers up to the square root, pulling out each factor as it finds one. What’s left at the end is either 1 or a final prime factor. For a number near the 10 trillion limit that’s at most about 1.6 million divisions, which a browser does in a moment. The same method finds the previous and next primes by testing the numbers on each side in turn.
Prime factorization is unique: every whole number above 1 breaks down into primes in exactly one way, apart from the order. That’s why factorizations are handy for finding a greatest common factor and least common multiple or for simplifying fractions and square roots.