⚡ 2026 Edition · Free Forever

Prime Number Checker — is it prime or composite?

Instantly test whether a number is prime or composite. See the smallest divisor that settles it, the nearest primes above and below, a divisor-test diagram, and an AI explanation of the logic.

Step-by-step Visual diagram AI insights Private & free

Prime Number Checker

Live · BigInt-safe
Tip: enter one whole number. Press Enter to check.
Quick answer

What is a prime number?

A prime number is a whole number greater than 1 with exactly two divisors: 1 and itself. 97 is prime; 100 is composite because it has extra divisors. To test a number you only need to check divisors up to its square root.

Why this tool

A clear yes/no, with the reasoning

See exactly which divisor (if any) decides the answer — no black box.

Square-root shortcut

Only divisors up to √n are tested — fast and mathematically complete.

Nearest primes

See the previous and next prime numbers around your input.

Divisor diagram

A grid shows each tested divisor and highlights the one that proves compositeness.

How it works

Check a number in three steps

1

Enter a number

Type any whole number, e.g. 97.

2

Trial division runs

We test divisors from 2 up to the square root.

3

Read the verdict

Get prime/composite, the smallest divisor, nearest primes and an AI note.

Worked examples

Prime check examples

Tap any row to load it into the calculator.

NumberPrime?Why
2Yessmallest prime
97Yesno divisor ≤ √97
100Nodivisible by 2
561No3 × 11 × 17 (Carmichael)
7919Yesthe 1000th prime
12345Nodivisible by 5
1Noneither prime nor composite
51No3 × 17
91No7 × 13
57No3 × 19
89Yesno divisor ≤ √89

How to check if a number is prime

Test whether any integer from 2 up to the square root of the number divides it evenly. If none does, the number is prime; if one does, it is composite. You can stop at the square root because any factor larger than it must pair with a smaller one you already tested.

Quick shortcuts

  • Even numbers above 2 are never prime.
  • If the digits sum to a multiple of 3, the number is divisible by 3.
  • Numbers ending in 0 or 5 (above 5) are divisible by 5.

Worked example: 97

√97 ≈ 9.8, so we test 2, 3, 5, 7. None divides 97 evenly, so 97 is prime.

Beware "pseudoprimes" like 561 = 3 × 11 × 17, which fool some quick tests — true trial division still catches them.

Why prime testing matters

  • Cryptography — RSA keys are built from large primes.
  • Hashing — prime table sizes reduce collisions.
  • Number theory — primes are the building blocks of every integer.
FAQ

Frequently asked questions

How do you know if a number is prime?

Check whether any integer from 2 up to its square root divides it evenly. If none does, it is prime; otherwise it is composite.

Is 1 a prime number?

No. A prime must have exactly two distinct divisors. 1 has only one divisor, so it is neither prime nor composite.

Is 2 a prime number?

Yes — 2 is the smallest and the only even prime number.

Why only test up to the square root?

Any divisor larger than the square root pairs with a smaller divisor you have already checked, so testing past √n is unnecessary.

What is a composite number?

A composite number is a whole number greater than 1 that has at least one divisor other than 1 and itself, such as 100 or 561.