Calcist

Style

Buttons

Spacing

How much to show

Decimal places

Text size

Prime number checker

Enter a whole number to see if it's prime. If it isn't, you'll see its smallest factor. Below, list every prime between two numbers.

Primes in a range

Private: calculated on your device. Nothing you type is sent anywhere.

Next: See every factor and a factor tree with the factor calculator.

How primality is checked

A prime number is a whole number greater than 1 whose only factors are 1 and itself. To test one:

  1. Divide by the primes up to 1,009. If one divides evenly, the number isn't prime. If none do and the number is below 1,026,169 (that's 1,013²), it is prime.
  2. Otherwise run the Miller–Rabin test using the first 13 primes (2 to 41) as bases. It has been proven that no composite number below 3.3 × 10²⁴ passes all 13, so for every 64-bit number, and well beyond, the answer is certain.
  3. For even larger numbers (up to 100 digits), the test uses 40 bases. No composite is known that passes, but this is a probable-prime test, and the result says so.
n − 1 = 2s × d; n passes for base a if ad ≡ 1, or a2r·d ≡ −1 (mod n) for some r < s

Worked examples

  • 97: √97 ≈ 9.85, and none of 2, 3, 5 or 7 divides 97, so it's prime.
  • 91: 91 = 7 × 13, so it's not prime, even though it looks like it might be.
  • 561: 561 = 3 × 11 × 17. It's the smallest Carmichael number, which fools the simpler Fermat test, but Miller–Rabin catches it.
  • 2,305,843,009,213,693,951: that's 2⁶¹ − 1, a Mersenne prime, confirmed instantly.

How many primes are there?

Up toNumber of primes
10025
1,000168
10,0001,229
100,0009,592
1,000,00078,498

Primes thin out slowly: near a number n, roughly 1 in every ln(n) numbers is prime. There are infinitely many of them, as Euclid proved.

Limits

  • Single numbers: up to 100 digits. Answers are proven for numbers below 3.3 × 10²⁴ and probable above that.
  • Ranges: up to 1,000,000 numbers wide when the numbers are below 1012, or 10,000 wide above that. Up to 1,000 primes are listed, but the count is always complete.
  • Full factorizations are shown for numbers below 1019; see the factor calculator.

Sources

How we checked this

Before every update, this calculator is run in a real browser with these known answers, and it must match all of them:

  • 1 to 100: share is 25% (100 numbers) ✓
  • 97 is prime ✓
  • 2⁶¹ − 1 is prime ✓
  • 561 = 3 × 11 × 17 is not prime ✓
  • The next prime after 10¹² is 1,000,000,000,039 ✓
  • 1 is not prime ✓
  • 25 primes from 1 to 100 ✓
  • 78,498 primes below 1,000,000 ✓

Last checked October 26, 2026. Spotted something wrong? The math is done in your browser with the formula shown on this page, so you can check any result by hand.

Add this calculator to your website (free)

Paste this code into any web page. The calculator works on your page, resizes itself, has no ads and no tracking, and nothing your visitors type is sent anywhere. More about embedding.

Questions people ask

Is 1 a prime number?

No. A prime needs exactly two different factors, 1 and itself. 1 has only one factor, so it's neither prime nor composite.

Is 2 a prime number?

Yes. 2 is the smallest prime and the only even one. Every other even number is divisible by 2.

Is 51 prime?

No. 51 = 3 × 17. A quick check: its digits add to 6, which is divisible by 3, so 51 is too.

What are the prime numbers from 1 to 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. That's 25 primes.

How do I check if a number is prime by hand?

Divide it by each prime up to its square root. If none divides evenly, it's prime. For 113, √113 ≈ 10.6, and 2, 3, 5 and 7 don't divide it, so 113 is prime.

Related calculators