← All blog posts

How to Check If a Number Is Prime (Step by Step)

WhiteUI · A plain-English guide to the Prime Number Checker

Checking whether a number is prime is a short, mechanical job: test divisors up to the square root, and stop at the first one that divides evenly. Try it on the Prime Number Checker as you read.

The method

To test n, try every divisor from 2 up to √n. If a number had a factor bigger than its square root, the matching smaller factor would already have been found — so there is nothing to gain by testing further.

Worked example: 97

√97 is about 9.85, so only 2, 3, 5 and 7 need testing. 97 is odd, so 2 fails. 9 + 7 = 16, not divisible by 3, so 3 fails. 97 does not end in 0 or 5, so 5 fails. 97 ÷ 7 = 13.86, not whole, so 7 fails. Nothing divides it — 97 is prime.

Is 97 prime? √97 ≈ 9.85 → test 2, 3, 5, 7
97 ÷ 2 = 48.5 — no
97 ÷ 3 = 32.33 — no
97 ÷ 5 = 19.4 — no
97 ÷ 7 = 13.86 — no
Result: prime

The divisor checklist for 97

÷ 2 → 48.5 ✗÷ 3 → 32.33 ✗÷ 5 → 19.4 ✗÷ 7 → 13.86 ✗Prime

Four failed divisors are enough: nothing up to √97 divides it.

A composite example: 91

√91 is about 9.54, so test 2, 3, 5 and 7 again. 91 is odd, 9 + 1 = 10 is not divisible by 3, it does not end in 0 or 5 — but 91 ÷ 7 = 13 exactly. So 91 = 7 × 13 and is composite, with smallest factor 7.

The shortcuts

Even numbers (except 2) are composite. Numbers ending in 5 (except 5) are composite. If the digits add up to a multiple of 3, the number is divisible by 3.

Frequently asked questions

How do I check if a number is prime?

Test divisors from 2 up to the square root of the number. If none divides evenly, it is prime.

Why only up to the square root?

Factors come in pairs that multiply to n, and one of each pair is always at or below √n. Testing up to √n catches every factor.

Is 91 prime?

No — 91 = 7 × 13, so it is composite.

Is 1 prime?

No. 1 has only one factor, so it is neither prime nor composite.

More guides on the Prime Number Checker

Try it yourself

Check whether any number is prime, and see the primes around it — free, in your browser.

Open the Prime Number Checker