Prime Number Calculator

One engine for everything you might want to know about a whole number. Hand it a number and it tells you whether that number is prime, and if it is not, exactly what it is made of — the full prime factorisation, how many divisors it has, what they sum to, Euler's totient, the nearest prime on either...

YOUR NUMBER

WORTH TRYING

97 IS

PRIME

PRIME GAP TO NEXT

+4

Exactly two divisors, 1 and itself. Previous prime 89, next 101.

Prime factorisation

97

Number of divisors

2

Sum of divisors

98

Totient φ(n)

96

Previous prime

89

Next prime

101

FACTOR BREAKDOWN

PRIME

POWER

CONTRIBUTES

97

1

97

STEPS

1

Trial-divide 97 by every prime up to √97 ≈ 9 — beyond that a factor would have a partner below it

2

No divisor found, so 97 has exactly two divisors: 1 and itself

3

Every prime above 3 sits next to a multiple of 6 — here 97 is 6 × 16 + 1

4

97 is PRIME

SIEVE OF ERATOSTHENES

READY — NOTHING CROSSED OUT YET99 LEFT1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001 is set aside — it is neither prime nor composite0 of 74 strikes

Two thousand years old and still the fastest way. Take the first uncrossed number, 2, and strike out every multiple of it. Move to the next survivor, 3, and repeat. Each pass can start at the square of its prime, because anything smaller was already struck by a smaller factor — which is why the passes get shorter and stop entirely once the prime exceeds √100. Whatever survives is prime. Your number 97 is outlined in gold.

HOW MANY PRIMES BELOW x — AND WHAT THE THEORY PREDICTS

10
4 vs 4
100
25 vs 22
1,000
168 vs 145
10,000
1,229 vs 1,086
100,000
9,592 vs 8,686

Actual count against x ÷ ln x. At x = 10 the estimate overshoots slightly; from 100 upward it runs low, and from 1,000 onward the gap narrows steadily — a ratio of 1.16 at a thousand down to 1.10 at a hundred thousand. That it tends to 1 at all is the Prime Number Theorem, and how slowly it does so is why the proof took a century to find.

Proved, not guessed. Primality here uses a deterministic Miller–Rabin test with a fixed witness set that is proven correct for every number this page accepts, so a result of PRIME is a proof rather than a probability. Ranges are sieved up to 200,000; single numbers are tested up to 4,503,599,627,370,495.

Live simulation · drawn to scale · updates as you type

Created with❤️byeaglecalculator.com

HOW TO USE

  1. 1

    In TEST mode, type any whole number from 2 up to about four and a half quadrillion. You get the verdict immediately, along with the factorisation if it is composite, the gap to the next prime if it is not, and six derived quantities including the divisor count and Euler's totient.

  2. 2

    Try the suggested numbers before anything else. 91 looks prime and is 7 × 13. 561 fools the Fermat test but not this one. 8128 is a perfect number, 2147483647 is the Mersenne prime 2³¹ − 1, and 600851475143 factorises into four primes in a fraction of a second.

  3. 3

    Switch to RANGE to sieve an interval up to 200,000. You get every prime in it, the count, the density as a percentage, the twin pairs and the sum. The quick-range buttons cover the intervals people usually want.

  4. 4

    Watch the sieve on the right, or drag the scrubber through it a pass at a time. If your number is 100 or below it is outlined in gold on the grid, so you can see whether it survives or gets struck, and by which prime.

WORKED EXAMPLE

Is 97 prime? The square root of 97 is about 9.85, so the only primes worth trying are 2, 3, 5 and 7 — anything larger would need a partner smaller than 9.85, and we are already checking those. 97 is odd, so 2 fails. Its digits sum to 16, which is not a multiple of 3, so 3 fails. It does not end in 0 or 5, so 5 fails. And 7 × 13 = 91, 7 × 14 = 98, so 7 fails too. No divisor found. 97 is prime — the largest two-digit prime, in fact. Its divisor count is 2, its divisor sum is 98, and φ(97) = 96, since every one of the 96 numbers below it is coprime to it. The previous prime is 89 and the next is 101, so 97 sits in a gap of 4 either side. Now contrast 91, which most people would also guess is prime. It is odd, its digits sum to 10, and it does not end in 0 or 5 — every quick test passes. But 7 divides it: 91 = 7 × 13. That is why the square-root rule matters. Stopping at 5 because the small tests passed would have given the wrong answer.

THE FORMULAS

Primeexactly two divisors: 1 and n
Trial division limittest primes up to √n only
Fundamental theoremn = p₁^a¹ × p₂^a² × … uniquely
Number of divisorsd(n) = Π (aᵢ + 1)
Sum of divisorsσ(n) = Π (pᵢ^(aᵢ+1) − 1)/(pᵢ − 1)
Euler totientφ(n) = n · Π (1 − 1/pᵢ)
Totient of a primeφ(p) = p − 1
Sieve pass startbegin each pass at p²
Prime Number Theoremπ(x) ≈ x ÷ ln x
Twin primesp and p + 2 both prime
Mersenne prime2^p − 1, with p itself prime
Perfect numberσ(n) − n = n

FREQUENTLY ASKED QUESTIONS

RELATED CALCULATORS

MORE NUMBER THEORY CALCULATORS

Was this calculator helpful?

Last updated: July 28, 2026 · Formula verified · Deterministic Miller–Rabin, so a result of PRIME is proven rather than probable · Eagle-eyed accuracy for every calculation.