Prime Number Checker

Check whether any positive integer is prime, see the trial-division work step by step, and list every prime in a chosen range.

Prime Number List Generator

List every prime between a lower and upper limit. Uses a Sieve of Eratosthenes under the hood; upper limit capped at 100,000.

What is a prime number?

A prime number is an integer greater than 1 whose only positive divisors are 1 and itself. 2, 3, 5, 7, 11, 13, 17, 19 and 23 are the first nine primes. Any integer greater than 1 that isn't prime is called composite — it can be written as a product of two smaller positive integers, each greater than 1.

1 is a special case: it has only one divisor, so it fits neither definition. By convention it is neither prime nor composite. 2 is the only even prime; every other even number has 2 as a divisor.

How the prime check works, piece by piece

Each card explains one thing this tool does with your input — the trial-division bound it uses, the shortcut that skips most candidates, and the reason primes are worth checking at all.

Trial division stops at √n

The tool divides n by candidates up to √n. If n = a · b with a ≤ b, then a ≤ √n — any factor larger than √n already has a smaller partner we would have found.

if n = a · b
a ≤ b
then a ≤ √n
1a√nbna · b = n → a ≤ √nstop testing at √n
Example
Given
n = 97, √97 ≈ 9.85
Substitute
test 2, 3, 5, 7 — none divides 97
Answer
97 is prime

6k ± 1 skips two-thirds of candidates

After ruling out 2 and 3, every remaining prime has the form 6k − 1 or 6k + 1. Anything else is divisible by 2 or 3, so the tool never tests those candidates.

test 2, 3
then p ∈ {5, 7, 11, 13, 17, 19, …}
12345678910111213test 2, 3, then only 6k±1skips ⅔ of candidates
Example
Given
candidates ≤ 20
Substitute
keep 5, 7, 11, 13, 17, 19
Answer
6 tests instead of 18

Fundamental theorem of arithmetic

Every integer greater than 1 factors into primes in exactly one way (up to order). That's why the tool also shows the prime factorization when a number is composite — it's the unique "DNA" of the number.

n = p₁^a₁ · p₂^a₂ · … · pₖ^aₖ
6023021560 = 2² · 3 · 5 (unique)
Example
Given
n = 60
Substitute
60 = 2 · 30
= 2 · 2 · 15
= 2 · 2 · 3 · 5
Answer
2² · 3 · 5

Features of this calculator

  • Instantly checks primality for integers up to 100,000,000
  • Shows the trial-division work step by step
  • Falls back to the full prime factorization when the number is composite
  • Bonus tool: generates every prime in a range using a Sieve of Eratosthenes
  • Uses the 6k ± 1 shortcut and a √n bound — no wasted divisions

Frequently asked questions

+What is the smallest prime number?

2. It's also the only even prime, because every larger even number has 2 as a divisor.

+Is 1 a prime number?

No. A prime is defined as an integer greater than 1 with exactly two positive divisors. 1 has only one, so it falls outside both the prime and composite definitions.

+How can 91 look prime but not be?

91 doesn't end in an even digit or a 5, and it isn't divisible by 3, so the quickest divisibility rules miss it. But 91 = 7 × 13, which trial division up to √91 ≈ 9.5 catches immediately.

+Why is there an upper limit on the input?

Trial division stays fast well into the tens of millions, but past that, browser-side checks start to lag. Cryptographic-scale primes use probabilistic tests (Miller–Rabin) on dedicated hardware, not a single tab of JavaScript.

Related calculators