Number theory
How to Test for a Prime Number
Updated October 2, 2026
A prime number is an integer greater than 1 with exactly two positive factors: 1 and itself. To test a number, rule out small factors first, then check up to its square root.
Quick definition
- Prime: 2, 3, 5, 7, 11, 13, …
- Not prime: 1 (by definition), and composites like 4, 9, 15, 91.
Divisibility rules (2 through 10)
Before you grind through every divisor, use the rules. CalcSolver's Divisibility Rules Practice checks a number against each rule and shows why it passes or fails.
- 2: last digit even
- 3: digit sum divisible by 3
- 4: last two digits form a multiple of 4
- 5: last digit 0 or 5
- 6: divisible by both 2 and 3
- 8: last three digits form a multiple of 8
- 9: digit sum divisible by 9
- 10: last digit 0
The square-root shortcut
If n is composite, it has a factor ≤ √n. So you only need to test prime divisors up to √n. Example: for 97, √97 ≈ 9.8, so check primes up to 7. None divide 97, so 97 is prime.
Worked check: is 91 prime?
- 91 is odd → not divisible by 2.
- Digit sum 9 + 1 = 10, not divisible by 3.
- Doesn't end in 0 or 5 → not divisible by 5.
- 91 ÷ 7 = 13 exactly → factors 1, 7, 13, 91 → not prime.
Related number tools
For shared factors and multiples, use the LCM and GCF Calculator.