Prime Number Calculator
Test any number up to a trillion for primality, get its full factorisation, the nearest primes either side, and how many primes lie below it.
Prime Number Calculator: with the default inputs, prime? is No — 600,851,475,143 is composite.
Whole numbers from 0 up to 1,000,000,000,000.
- Prime factorisation
- 71 × 839 × 1,471 × 6,857
- Number of divisors
- 16Multiply (exponent + 1) across the factorisation.
- Nearest prime below
- 600,851,475,067
- Nearest prime above
- 600,851,475,149
- Primes below n
- 23,038,927,505
Assumptions
- Inputs are whole numbers from 0 to 10^12; the factorisation is complete and exact across that whole range.
- Primality uses deterministic Miller-Rabin with the 12 smallest prime bases, proven correct below 3.3 × 10^24.
- The prime count is exact by sieve up to 2,000,000 and a logarithmic-integral estimate above it (flagged in the results).
| Prime | Exponent | Contributes |
|---|---|---|
| 71 | 1 | 71^1 = 71 |
| 839 | 1 | 839^1 = 839 |
| 1,471 | 1 | 1,471^1 = 1,471 |
| 6,857 | 1 | 6,857^1 = 6,857 |
Multiplying the "contributes" column back together returns 600,851,475,143. Every whole number above 1 has exactly one such factorisation — that is the fundamental theorem of arithmetic.
How this is worked out
The formula
n is prime when its only positive divisors are 1 and n. Trial division: test divisors d = 2, 3, 5, 7, … while d² ≤ n. Miller-Rabin with the bases 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 is a deterministic proof of primality for every n < 3.3 × 10^24. Number of divisors from n = p₁^e₁ × p₂^e₂ × … is (e₁ + 1)(e₂ + 1)… Prime number theorem: π(x) ≈ li(x), the logarithmic integral.
Open How it’s calculated above to see this worked through with your own numbers.
What you enter
- Number to test (n)
- Whole numbers from 0 up to 1,000,000,000,000.from 0 to 1000000000000 · whole numbers only · defaults to 600851475143
What you get back
- Prime?main answer
- Prime factorisation
- Number of divisors
- Multiply (exponent + 1) across the factorisation.
- Nearest prime below
- Nearest prime above
- Primes below n
What this assumes
- Inputs are whole numbers from 0 to 10^12; the factorisation is complete and exact across that whole range.
- Primality uses deterministic Miller-Rabin with the 12 smallest prime bases, proven correct below 3.3 × 10^24.
- The prime count is exact by sieve up to 2,000,000 and a logarithmic-integral estimate above it (flagged in the results).
About this calculator
A prime number has exactly two positive divisors: 1 and itself. That short definition carries an enormous amount of structure — every whole number above 1 factors into primes in exactly one way, which is why primes are called the atoms of arithmetic.
How to use it
Type any whole number up to a trillion. You get a verdict, the complete factorisation, the primes immediately either side, and a count of how many primes lie below it.
How the answer is reached
Two methods, cross-checking each other:
- Trial division finds the actual factors. It tests candidate divisors up to √n, because if n = a × b then one of the two factors must be at or below the square root. That is why testing a trillion needs only a million divisions, not a trillion.
- Miller-Rabin proves primality. With the fixed witness set 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 it is deterministic — not probabilistic — for every number below 3.3 × 10²⁴, a result established by exhaustive verification (Sorenson & Webster, 2015). Well inside that range, its answer is a proof.
Why the cap at 10¹²: trial division is bounded at a million candidate divisors. Since the input can be no larger than 10¹², anything left after removing every prime factor below 10⁶ must itself be prime — a composite leftover would need two factors above 10⁶ and so exceed 10¹². The factorisation is therefore always complete, and always fast. Beyond that limit, honest factoring needs Pollard's rho or the quadratic sieve, so the calculator stops rather than hanging.
Reading the other numbers
- Number of divisors comes straight from the factorisation: add one to each exponent and multiply. 12 = 2² × 3 has (2+1)(1+1) = 6 divisors.
- Primes below n is counted exactly by sieve up to two million. Above that it is the logarithmic-integral estimate li(n) from the prime number theorem, labelled as an estimate — near 10¹² it is right to about one part in a million, which is close but not exact, and pretending otherwise would be dishonest.
- Nearest primes show how uneven the gaps are. Primes thin out as numbers grow — the average gap near x is about ln x, so near a trillion it is roughly 28 — but they never run out. Euclid proved that over two thousand years ago.
Common misconceptions
1 is not prime. It has only one divisor, not two, and treating it as prime would break unique factorisation (12 = 2²×3 = 1×2²×3 = 1²×2²×3…). 2 is prime, and is the only even prime — every other even number has 2 as a proper divisor. And a number ending in 5 is divisible by 5, so 5 is the only prime ending in 5.
Frequently asked questions
▸Is 1 a prime number?
No. A prime has exactly two distinct positive divisors and 1 has only one. Excluding it is what makes prime factorisation unique.
▸How do you check if a large number is prime?
Trial division up to the square root is enough and is what finds actual factors. For a fast yes/no on large numbers, Miller-Rabin with a fixed set of witness bases is deterministic below 3.3 × 10²⁴.
▸What is the largest prime factor of 600851475143?
6,857. The full factorisation is 71 × 839 × 1471 × 6857.
▸How many prime numbers are there below one million?
78,498. This calculator counts them exactly by sieve up to two million and estimates with the logarithmic integral above that.
▸Is 2 the only even prime?
Yes. Every other even number is divisible by 2 as well as by 1 and itself, so it has at least three divisors and cannot be prime.
Put this calculator on your own site
A working prime checker, free for any site, with no ads and no sign-up. It resizes to fit wherever you paste it and updates itself as this page improves.
Paste this anywhere. It works on any site, carries no ads, never expires, and always shows the current version.
Prime Number Calculator by CalculateItNow
The page's own title. The clearest description of what the link leads to.
The credit line sits outside the widget on purpose, so it is a real link on your page rather than one buried in a frame. Please keep it — it is what pays for CalculateItNow staying free and ad-free. The script only resizes the widget to fit its contents; drop it and the widget still works.
Browse every calculator widget·How to add it to WordPress, Squarespace or Wix
Related calculators
The questions people ask next to a prime checker.
Greatest common divisor and least common multiple of 2–4 whole numbers, with Euclid's algorithm written out line by line and the prime factorizations.
n! computed exactly with big integers up to 1000, in scientific notation beyond, plus the digit count, trailing zeros and the gamma function for non-integers.
a mod b with the quotient and remainder, showing where the mathematical modulo and the % operator in C, Java and JavaScript disagree on negative numbers.
Arithmetic and geometric sequences: the nth term, the sum of the first n terms, the first ten terms listed, and the infinite sum when the series converges.
Square roots, cube roots and nth roots with the radical simplified (√72 = 6√2) via prime factorization, plus the number squared and cubed.
Every factor of a number, its prime factorisation, factor pairs, the divisor count and sum, and whether it is prime, perfect, abundant or deficient.