Skip to main content
MathKit

Prime Number Checker

Enter an integer to instantly test whether it is a prime number.

Calculator

Use the Prime Number Checker

Result

—

Formula

trial division up to √n

Step-by-step

  1. 1

    Enter the number

    Any integer greater than 1 can be tested.

  2. 2

    Read the verdict

    The result shows whether the number is prime.

Worked example

Example input: n: 97

Result: 97 is prime

Related tools

Frequently asked questions

Is 1 a prime number?

No. A prime number must have exactly two distinct factors, and 1 has only one factor — itself. That is why the checker treats 0 and 1 as not prime.

Is 0 a prime number?

No. Primes must be greater than 1 and have exactly two factors, while 0 is divisible by every nonzero integer — it has infinitely many factors, not exactly two.

How does the prime check work?

The calculator uses trial division up to √n. If no number from 5 up to √n divides n evenly (after ruling out multiples of 2 and 3), the number is prime.

How large a number can I check?

Any integer that JavaScript can represent exactly works reliably — up to 9,007,199,254,740,991. Beyond that, values lose integer precision and the result can no longer be trusted.

Why is 97 prime but 95 not?

95 = 5 × 19, so it has factors other than 1 and itself. 97 has no divisors between 2 and √97 ≈ 9.8, so it is prime.

What is a prime number?

A whole number greater than 1 whose only factors are 1 and itself. The first few are 2, 3, 5, 7, 11, 13, 17, 19, 23 — and 2 is the only even prime.

How do you check if a number is prime by hand?

Test divisibility by every prime up to √n. For 89: √89 ≈ 9.4, so only 2, 3, 5 and 7 need a check — none divides 89, so 89 is prime. Four checks instead of 88 saves nearly all the work.

Useful links