Prime Number Checker

Is n prime? Trial division up to √n; identifies smallest divisor and nearest primes if composite.

Inputs

Result

Loading calculator…

General calculation reads

Amazon affiliate

As an Amazon Associate we may earn from qualifying purchases. This does not add cost for you.

How to use this calculator

  • Enter integer.
  • Read result + nearest primes.

About this calculator

A prime is a positive integer >1 with exactly two divisors: 1 and itself. The 6k±1 trial-division algorithm tests divisors up to √n: every prime >3 is of form 6k±1, so we skip 2/3 of integers. For n up to 10^15, this finishes in milliseconds. Beyond that, probabilistic tests (Miller-Rabin) are used. Famous primes: 2 (only even), 7 (Mersenne), 25-million-digit primes for crypto.

Frequently asked

Is 1 prime?+
No — by convention, primes are integers ≥2 with exactly two divisors. 1 has only itself.
Is 0 prime?+
No — 0 has every positive integer as a divisor.
Why test up to √n?+
If n has a factor f > √n, then n/f is a factor < √n. So checking up to √n catches all composites.
Why 6k±1 optimization?+
Every integer is 6k, 6k±1, 6k±2, or 6k+3. The 6k, 6k±2, 6k+3 forms are divisible by 2 or 3 — skip them. Only 6k±1 needs testing.
How many primes?+
Infinite (Euclid). About n/ln(n) primes ≤ n by prime number theorem.

Related calculators

More tools you might like

Hand-picked tools that pair well with this one — same audience, same intent.