Prime Number Calculator
Check whether any whole number is prime, with the trial divisions explained.
The formula behind it
n is prime ⟺ n > 1 and no d ∈ [2, √n] divides n- d
- candidate divisor
- √n
- testing beyond the square root is unnecessary
If n had a factor larger than √n, its cofactor would be smaller than √n — so checking up to the square root is enough. The calculator tests 2, 3, then 6k±1 candidates, the standard optimization.
How to use this calculator
- 1
Enter a whole number.
- 2
Press Calculate.
- 3
Non-primes show their first found factor; primes confirm the trial divisions performed.
Worked examples
A classic prime
97 — not divisible by 2, 3, 5, 7 (7² = 49 < 97, next check 11² = 121 > 97), so prime.
A near-miss
91 = 7 × 13 fails at 7 — a famous example because it looks prime at a glance.