Prime Number Checker

Free prime number checker: test whether any integer is prime, get the prime factors of composite numbers, and find the nearest primes above and below.

Enter your values and press Calculate.

Results are estimates for planning purposes and are not financial, medical, or professional advice.

How to Use the Prime Number Checker

Enter any whole number to find out instantly whether it is prime, see its prime factors if it is composite, and discover the closest primes nearby — handy for number theory homework and programming puzzles.

  1. Enter an integer of 2 or more.
  2. Press calculate.
  3. Read whether the number is prime or composite.
  4. For composites, study the prime factorization. For primes, note the neighboring primes above and below.

How Primality Is Tested

The checker uses trial division: it tests divisibility by 2 and then by every odd integer up to the square root of the number. If none divide evenly, the number is prime. Checking only up to the square root is enough, because factors come in pairs: if n = a × b, at least one of a and b is no bigger than √n. For composites it keeps dividing out the smallest factor repeatedly to build the full prime factorization. It then scans downward and upward to locate the nearest primes on each side.

Quick hand-check shortcuts for the square-root rule: skip even numbers past 2, add the digits to test divisibility by 3 (a multiple of 3 has a digit sum divisible by 3), and anything ending in 5 is divisible by 5. For 143, the square root is about 11.96, so you test only 2, 3, 5, 7, and 11 — and 143 ÷ 11 = 13, so it is composite. Five checks, not one hundred and forty.

Example

Testing 91: trial division finds 91 divided by 7 equals 13, so 91 is composite with prime factors 7 and 13. Scanning nearby, the closest lower prime is 89 and the closest higher prime is 97. Testing 97: divisibility checks up to √97 ≈ 9.8 (2, 3, 5, 7) all fail, so 97 is prime; its nearest primes are 89 below and 101 above.

The First 25 Primes

2 3 5 7 11
13 17 19 23 29
31 37 41 43 47
53 59 61 67 71
73 79 83 89 97

Numbers That Look Prime But Aren’t

Some composites are famous traps. They end in odd digits, fail the obvious checks at a glance, and catch students again and again:

Number Factorization
51 3 × 17
57 3 × 19
87 3 × 29
91 7 × 13
121 11 × 11
143 11 × 13
169 13 × 13
289 17 × 17
529 23 × 23

The pattern: odd squares of primes (121, 169, 289, 529) look safe because their digit tests are clean. Test them against their own root and they fold immediately.

Prime factorization: 91 equals 7 times 13 factor tree
Prime factorization: 91 equals 7 times 13 factor tree
Sieve of Eratosthenes: finding prime numbers visualized
Sieve of Eratosthenes: finding prime numbers visualized

Why Primes Matter

Primes are the atoms of arithmetic: every whole number factors uniquely into primes, a fact called the fundamental theorem of arithmetic. Modern encryption, including the RSA system securing online banking, relies on the difficulty of factoring products of two huge primes — multiplying them is easy, splitting them back apart is not. Primes also appear in nature, such as cicadas emerging on prime-numbered year cycles to dodge predators whose cycles would otherwise line up. And mathematicians still hunt for patterns in their distribution: the largest known primes are Mersenne primes with tens of millions of digits, found by distributed computing projects, while Euclid’s proof from over two thousand years ago already settled that the primes never end.

Frequently Asked Questions

What is a prime number?

A whole number greater than 1 with exactly two divisors: 1 and itself. Examples are 2, 3, 5, 7, and 11.

Is 1 a prime number?

No. By definition primes must have exactly two divisors, and 1 has only one.

What is prime factorization used for?

It underpins cryptography, simplifies fractions, and helps find greatest common divisors and least common multiples. RSA encryption multiplies two enormous secret primes; anyone can use the product as a public key, but only the key holder who knows the factors can decrypt messages efficiently.

What is the largest known prime?

Mersenne primes hold the records, found by distributed computing projects, with tens of millions of digits.

Are there infinitely many primes?

Yes. Euclid proved over two thousand years ago that the primes never end. His elegant argument shows that multiplying all known primes and adding one always produces a number with a new prime factor, so the list can never be complete.

How can I check whether a number is prime by hand?

Test divisibility by primes only up to the square root of the number. For 143, the square root is about 12, so test 2, 3, 5, 7, and 11: 143 divides by 11 to give 13, so it is composite. If nothing divides it by the square root, the number is prime.

Is 2 the only even prime number?

Yes. Every even number above 2 is divisible by 2, so it has at least three divisors and cannot be prime. Two is also the smallest prime, which is why this checker tests divisibility by 2 first.

Related Calculators

Try our Scientific Calculator and Number Sequence Finder for more math tools.


Scroll to Top