Mathematics · Updated 2026

Prime Number Calculator

Check if any number is prime, find its complete prime factorization, or list all prime numbers up to a given value using the Sieve of Eratosthenes.

Last updated · Record primes checked against GIMPS and the Prime Pages

Is it Prime?
Prime Factorization
List Primes to N
Divisors Shown
Our networkLegalCost.usWhat will your legal case cost?Official formulas for all 50 states. Free, no signup.Check your state
P
Prime Number Calculator
Check, Factorize & List Primes
Quick examples

Enter a number to check if it is prime, or switch to List mode to list all primes up to N.

Prime Numbers Properties & Significance

A prime number is a whole number greater than 1 whose only divisors are 1 and itself. 97 is prime; 91 is not, because 91 = 7 × 13. To check a number by hand, try dividing it by each prime up to its square root. The calculator above does this instantly for numbers up to 1018 and also shows the prime factorization, the divisors and the nearest primes.

A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The first primes are 2, 3, 5, 7, 11, 13, 17, 19, 23... 2 is the only even prime. There are infinitely many primes, proved by Euclid around 300 BC.

By the Fundamental Theorem of Arithmetic, every integer greater than 1 is either prime or can be expressed uniquely as a product of primes. This makes primes the fundamental building blocks of all integers.

How to Check if Prime

Test divisibility by all integers from 2 up to √n. If none divide evenly, n is prime. Example: is 97 prime? √97 ≈ 9.8. Test 2, 3, 5, 7. None divide 97. Yes, 97 is prime.

Sieve of Eratosthenes

To find all primes up to n: list numbers 2 to n, mark multiples of each prime as composite. Numbers that remain unmarked are prime. Efficient for finding primes in ranges.

Prime Factorization

Every composite number = unique product of primes. 360 = 2³ × 3² × 5. Used for GCF, LCM, simplifying fractions, and cryptography.

Primes in Cryptography

RSA encryption (used in HTTPS) relies on the difficulty of factoring the product of two large primes. A 2048-bit RSA key uses primes each about 300 digits long.

All 25 Primes Up to 100

RangePrimesCount
1 to 102, 3, 5, 74
11 to 2011, 13, 17, 194
21 to 3023, 292
31 to 4031, 372
41 to 5041, 43, 473
51 to 6053, 592
61 to 7061, 672
71 to 8071, 73, 793
81 to 9083, 892
91 to 100971

How Many Primes Are There?

Primes thin out as numbers grow, but slowly. The prime number theorem says the count up to n is roughly n divided by the natural log of n. From 100 upward the true count runs about 8% to 16% above that estimate.

Up toNumber of primesEstimate n ÷ ln nLargest prime below
10447
100252297
1,000168145997
10,0001,2291,0869,973
100,0009,5928,68699,991
1,000,00078,49872,382999,983

So about 1 in 4 numbers below 100 is prime, but only about 1 in 13 below a million. The List mode above runs the Sieve of Eratosthenes up to 100,000 and shows the same counts.

Numbers That Look Prime but Are Not

Odd numbers that do not end in 5 are easy to mistake for primes. These come up often in quizzes and fraction problems:

NumberFactorsNumberFactors
513 × 1714311 × 13
573 × 191617 × 23
873 × 2916913²
917 × 1318711 × 17
1197 × 1722113 × 17
1337 × 191,0017 × 11 × 13

Quick checks before you divide

  • By 3: add the digits. 51 gives 5 + 1 = 6 and 87 gives 8 + 7 = 15, both multiples of 3, so neither number is prime.
  • By 11: alternate adding and subtracting the digits. For 187 that is 1 − 8 + 7 = 0, so 11 divides it.
  • Stop at the square root. For 221, the square root is about 14.9, so only 2, 3, 5, 7, 11 and 13 need testing. 13 works: 221 = 13 × 17.
  • Remember the special cases. 2 is prime (the only even one), 1 is not prime, and 0 and negative numbers are never prime.

How the Calculator Checks Big Numbers

Trial division is fine for small numbers, but an 18-digit number would need about a billion divisions. The calculator uses the Miller-Rabin test with the twelve prime bases from 2 to 37, which is proven to give no wrong answers for any number below 264 (about 1.8 × 1019). It never trusts the simpler Fermat test, which is fooled by Carmichael numbers such as 561 = 3 × 11 × 17. Composite numbers are split with Pollard's rho method, so even a product of two 9-digit primes factors in a fraction of a second. For factors shared between numbers, try the GCF calculator or the LCM calculator.

Method and sources. Primality by trial division for small numbers and by the Miller-Rabin test with bases 2 to 37, deterministic below 2^64 (Feitsma and Galway enumeration of base-2 pseudoprimes); factoring by trial division and Pollard's rho method (1975); prime lists and counts by the Sieve of Eratosthenes, all computed in node with exact integers. Record primes: GIMPS list of known Mersenne primes and the Prime Pages (t5k.org) top 20 twin primes, both checked September 2026.

Prime Number Questions

A prime number is a natural number greater than 1 that can only be divided evenly by 1 and itself. Examples: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29. The number 1 is not prime (by definition). 4 is not prime because 4 = 2×2. 2 is the only even prime; all other even numbers are divisible by 2 and therefore composite.

Test divisibility by all integers from 2 up to the square root of the number. If any divide evenly, it is composite. If none do, it is prime. Example: is 127 prime? √127 ≈ 11.3. Test divisibility by 2, 3, 5, 7, 11. 127 is not divisible by any of these. Therefore 127 is prime. You only need to test up to √n because if n has a factor larger than √n, it must also have one smaller than √n.

Every composite number can be expressed as a unique product of prime numbers. This is the Fundamental Theorem of Arithmetic. Examples: 12 = 2² × 3. 60 = 2² × 3 × 5. 360 = 2³ × 3² × 5. To find it: divide by the smallest prime (2) repeatedly until it no longer divides, then try 3, 5, 7, etc. Prime factorization is used to find GCF and LCM, simplify fractions, and is the basis of RSA encryption.

Yes. Euclid proved this around 300 BC with an elegant proof: assume there are finitely many primes p1, p2, ..., pk. Form N = (p1 × p2 × ... × pk) + 1. N is either prime (contradicting our assumption) or has a prime factor not in our list (also a contradiction). Therefore infinitely many primes exist. They become less frequent among larger numbers but never stop entirely.

An ancient algorithm (Eratosthenes of Cyrene, ~240 BC) for finding all primes up to n. Method: (1) List all integers from 2 to n. (2) Starting with p=2, mark all multiples of p (except p itself) as composite. (3) Find the next unmarked number: this is the next prime. (4) Repeat until p² > n. All remaining unmarked numbers are prime. It is efficient because you start crossing out at p² (smaller multiples have already been handled).

A composite number is a natural number greater than 1 that is NOT prime. It has at least one factor other than 1 and itself. Examples: 4 (=2×2), 6 (=2×3), 8 (=2^3), 9 (=3^2), 10 (=2×5). The number 1 is neither prime nor composite. Every positive integer is exactly one of: prime, composite, or the number 1. There are infinitely many composite numbers just as there are infinitely many primes.

Twin primes are pairs of prime numbers that differ by exactly 2. Examples: (3,5), (5,7), (11,13), (17,19), (29,31), (41,43), (59,61), (71,73). The Twin Prime Conjecture states there are infinitely many twin prime pairs, but this has not been proved. The largest known pair, found in 2016, is 2996863034895 × 2^1290000 ± 1, with 388,342 digits each. Twin primes become increasingly rare among larger numbers but appear to never stop.

By modern definition, primes must be greater than 1. If 1 were prime, the Fundamental Theorem of Arithmetic (every number has a unique prime factorization) would break down: 12 could be written as 2²×3, or 1×2²×3, or 1²×2²×3, etc. infinitely many factorizations. Excluding 1 preserves uniqueness. This is a definitional choice made for mathematical convenience, not an arbitrary rule.

RSA encryption (used in HTTPS, TLS, digital signatures) relies on a simple asymmetry: multiplying two large primes is computationally easy, but factoring their product back into primes is computationally infeasible. A 2048-bit RSA key uses two primes each roughly 300 decimal digits long. Their product (the public key modulus) has about 617 digits. Current computers would need billions of years to factor it. This asymmetry underpins secure internet communication.

As of September 2026, the largest known prime is 2^136,279,841 − 1, a Mersenne prime with over 41 million digits, discovered in October 2024 by Luke Durant using the GIMPS (Great Internet Mersenne Prime Search) distributed computing project. Mersenne primes have the form 2^p − 1 where p itself is prime. Not all such numbers are prime, but all the largest known primes are Mersenne primes because they are especially efficient to test with the Lucas-Lehmer primality test.

No. Prime numbers are defined only for whole numbers greater than 1. 0 is divisible by every number, and negative numbers are outside the definition, so neither is prime or composite. The smallest prime is 2.

There are 25 primes below 100: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89 and 97. There are 168 below 1,000 and 1,229 below 10,000.

No. 91 = 7 × 13, so it is composite. It fools many people because it is odd, does not end in 5 and its digits add to 10, which is not a multiple of 3. Other common look-alikes are 51 (3 × 17), 57 (3 × 19) and 87 (3 × 29).