Prime Number Checker

Check if any number is prime, find its prime factors, or generate all prime numbers in a given range. A prime number is a natural number greater than 1 that has no divisors other than 1 and itself.

Prime Number Checker

First 20 Prime Numbers

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71 A number n is prime if no integer from 2 to √n divides it evenly.

Frequently Asked Questions

Is 1 a prime number?+
No. By definition, prime numbers must have exactly two distinct factors: 1 and themselves. The number 1 has only one factor (itself), so it's neither prime nor composite. This exclusion is important for the fundamental theorem of arithmetic (unique prime factorization).
What is prime factorization used for?+
Prime factorization breaks a number into its prime building blocks. It's used to find greatest common divisors (GCD), least common multiples (LCM), simplify fractions, and is the foundation of RSA encryption — the security of which relies on the difficulty of factoring large numbers.

What makes a number prime

A prime has exactly two distinct divisors: 1 and itself. 7 qualifies; 9 does not, because 3 divides it.

1 is not prime — it has only one divisor. This is not an arbitrary exclusion: treating 1 as prime would break the fundamental theorem of arithmetic, which states every integer above 1 factors into primes in exactly one way. If 1 were prime, 6 could be 2×3 or 1×2×3 or 1×1×2×3, and uniqueness would collapse.

Testing by hand

Trial division only needs to run up to the square root of the number. If no prime at or below √n divides n, then n is prime.

The reason is that factors come in pairs: if n = a × b, one of them must be at or below √n. Checking beyond that point only re-finds partners you have already tested.

Example: for 97, √97 ≈ 9.8, so test 2, 3, 5 and 7. None divide it, so 97 is prime.

Quick divisibility checks

  • 2 — last digit is even
  • 3 — digit sum divisible by 3
  • 5 — ends in 0 or 5
  • 11 — alternating digit sum divisible by 11

Why primes matter

Modern public-key cryptography rests on an asymmetry: multiplying two large primes is fast, while factoring the product back into those primes is computationally infeasible at sufficient size. The security of a great deal of internet traffic depends on that gap.

Primes thin out as numbers grow but never run out — Euclid proved there are infinitely many, by a short argument still taught today.