How to Check If a Number Is Prime (and Find Its Prime Factors)
Check if a number is prime by testing divisors up to its square root. Worked examples for 91, 97 and 221, prime factorisation and quick divisibility rules.
The short answer
To check if a number is prime, divide it by each prime number up to its square root. If none of them divides it exactly, it is prime; if one does, it is not. For example, √97 is about 9.8, so you only test 2, 3, 5 and 7. None divides 97, so 97 is prime. But 91 ÷ 7 = 13, so 91 is not prime. The free Prime Number Checker does this instantly and, for non-primes, shows the full prime factorisation.
What counts as a prime number
A prime number is a whole number greater than 1 with exactly two divisors: 1 and itself.
- 2, 3, 5, 7, 11 and 13 are prime.
- 4 (= 2 × 2), 9 (= 3 × 3) and 15 (= 3 × 5) are composite.
- 1 is neither prime nor composite, because it has only one divisor.
- 2 is the only even prime. Every other even number is divisible by 2.
The square root method, step by step
For 221: not even, digit sum 5 (not divisible by 3), doesn't end in 0 or 5, 221 ÷ 7 = 31.57, 221 ÷ 11 = 20.09, 221 ÷ 13 = 17 exactly. So 221 = 13 × 17 and is not prime.
Why the square root is enough: factors come in pairs that multiply to the number. If one factor is bigger than the square root, the other must be smaller, so it would already have turned up.
Worked examples
| Number | Square root (about) | Primes to test | Result |
|---|---|---|---|
| 51 | 7.1 | 2, 3, 5, 7 | 51 = 3 × 17, not prime |
| 91 | 9.5 | 2, 3, 5, 7 | 91 = 7 × 13, not prime |
| 97 | 9.8 | 2, 3, 5, 7 | Prime |
| 221 | 14.9 | up to 13 | 221 = 13 × 17, not prime |
| 2026 | 45.0 | 2 first | 2026 = 2 × 1013, not prime |
| 2027 | 45.0 | up to 43 | Prime |
| 8633 | 92.9 | up to 89 | 8633 = 89 × 97, not prime |
Numbers like 51, 57 (3 × 19), 87 (3 × 29) and 91 are classic traps because they "look" prime. A quick digit-sum check catches the multiples of 3.
Quick divisibility rules
These rules let you skip long division for the smallest primes:
| Divisible by | Rule | Example |
|---|---|---|
| 2 | Last digit is even | 1,358 |
| 3 | Digit sum is divisible by 3 | 57: 5 + 7 = 12 |
| 5 | Ends in 0 or 5 | 2,345 |
| 7 | Double the last digit and subtract it from the rest; the result is divisible by 7 | 91: 9 − 2 = 7 |
| 11 | Alternating sum of digits is divisible by 11 | 1,001: 1 − 0 + 0 − 1 = 0 |
Prime factorisation
Every whole number above 1 can be written as a product of primes in exactly one way (apart from order). To find it, keep dividing by the smallest prime that works:
360
- 360 ÷ 2 = 180
- 180 ÷ 2 = 90
- 90 ÷ 2 = 45
- 45 ÷ 3 = 15
- 15 ÷ 3 = 5
- 5 is prime
So 360 = 2³ × 3² × 5. The checker writes this as 2^3 × 3^2 × 5.
More examples: 1,001 = 7 × 11 × 13; 561 = 3 × 11 × 17; 999,999 = 3³ × 7 × 11 × 13 × 37; 1,234,567 = 127 × 9,721.
Prime factorisation is the quickest route to HCF and LCM, and to simplifying fractions. See how to find HCF and LCM for the next step.
How to use the Prime Number Checker
The tool has two tabs.
Prime Checker
360 = 2^3 × 3^2 × 5.List Primes
There are 25 primes up to 100 and 168 up to 1,000.
A limit on very large numbers: the checker uses ordinary JavaScript numbers, which are exact only up to 9,007,199,254,740,991. Beyond that, digits get rounded, so results for numbers with 16 or more digits may not be reliable.
The primes up to 100
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.
Common mistakes
- Calling 1 prime. It isn't, by definition.
- Calling every odd number prime. 9, 15, 21, 27, 33, 35, 39, 45, 49, 51, 57 and so on are odd but composite.
- Testing past the square root. It wastes time without changing the answer.
- Testing non-prime divisors. If a number isn't divisible by 2, it can't be divisible by 4, 6 or 8, so test primes only.
- Forgetting repeated factors. 360 has three 2s; keep dividing by the same prime until it no longer fits.
Related tools
Use the GCD and LCM Calculator once you have prime factors, and the Fraction Calculator to simplify fractions. For powers, roots and logarithms, the Scientific Calculator has the functions you need.
Frequently asked questions
How do you check if a number is prime?
Try dividing it by every prime up to its square root. If none divides it exactly, the number is prime. For 97, the square root is about 9.8, and 2, 3, 5 and 7 all leave a remainder, so 97 is prime.
Is 1 a prime number?
No. A prime has exactly two different divisors, 1 and itself. The number 1 has only one divisor, so it is neither prime nor composite.
Is 91 a prime number?
No. 91 = 7 × 13. It looks prime because it is odd, is not a multiple of 3 or 5 and does not end in 5, which is why it is a common trick question.
How many prime numbers are there between 1 and 100?
25. Between 1 and 1,000 there are 168. The List Primes tab of the Prime Number Checker shows them.
Why do I only need to check up to the square root?
If a number has a factor larger than its square root, the matching factor must be smaller than the square root, so you would already have found it.
Put this guide into practice with our free online tool — no signup required.
Open tool