Primality Tester
Is it prime? Exact answers for whole numbers up to 18 digits — smallest factor included when it's not.
Commas and spaces are stripped automatically. Digits only — no decimals.
How to use the Primality Tester
- Type a whole number — up to 18 digits. Commas and spaces are stripped for you.
- Press Test it — the verdict appears instantly: PRIME or COMPOSITE, with the smallest factor when there is one.
- Walk the number line — the previous/next prime buttons jump to the nearest primes around your number.
Why primality testing matters
Primes are the atoms of arithmetic — every whole number factors uniquely into primes. Modern encryption (RSA) rests on the fact that testing primality is easy while factoring huge numbers is brutally hard. This tool shows you both sides: the Miller-Rabin verdict arrives instantly, while the smallest factor of a stubborn composite may need real work. Play with 104729 (the 10,000th prime), then try a product of two big primes and watch trial division fail while Pollard's Rho cracks it.
Miller-Rabin, honestly explained
Miller-Rabin is usually described as "probabilistic" — each base tested halves the chance of a wrong answer. But with the right fixed set of bases, the test becomes deterministic: bases 2 through 37 provably decide every number below 264. Since this tool caps at 18 digits (under that ceiling), there's no probability involved at all — just a theorem doing the work.
- How do you know a huge number is really prime?
- This tester uses a deterministic Miller-Rabin test with 12 bases, which is mathematically proven correct for every number below 2^64. Since the tool caps inputs at 18 digits (below that ceiling), a 'prime' verdict is certain — not a probability.
- What does the 'smallest factor' mean for a composite number?
- Every composite number is a product of primes, and the smallest factor shown is the tiniest prime that divides it — 100's is 2, 49's is 7. The tool trial-divides by small primes, then uses Pollard's Rho algorithm to split numbers whose factors are both large. On rare occasions a composite's factors can't be isolated quickly, and the page says so honestly instead of guessing.
- Why is there an 18-digit limit?
- The primality test itself stays instant well beyond 18 digits, but factoring gets dramatically harder as numbers grow. 18 digits keeps every answer — prime verdicts and smallest factors — fast in a phone browser, while covering everything up to 999,999,999,999,999,999.
- What's the difference between prime and composite?
- A prime number is divisible only by 1 and itself (2, 3, 5, 7, 11...). A composite number has other divisors — 100 = 2 × 50. By convention, 0 and 1 are neither prime nor composite; primes start at 2.
- How do the next/previous prime buttons work?
- They step outward from your number — skipping evens — and test each candidate with the same Miller-Rabin test until a prime appears. Prime gaps below a quintillion are tiny (under 2,000), so the answer comes back instantly.
- Is my number sent anywhere?
- No. Every test runs in your browser with exact BigInt arithmetic — no floating-point rounding, no servers, nothing uploaded or tracked.
Kept alive by readers like you
Every tool in the codex is free. If they save you time, a small donation inscribes new pages.
DonateNeed help with this tool?
Found a bug, or have a suggestion for the codex? Write to us — a real human reads every message.
[email protected]More from the codex
Primality Tester
Is it prime? Certainty for numbers up to 18 digits.
Truth Table Generator
Full truth tables from any logic expression.
Open tool → LivePDF Text Extractor
Pull every page's text out of any PDF, in your browser.
Open tool → LiveBig Number Calculator
Exact arithmetic on numbers too big for a calculator.
Open tool → LiveBitwise Calculator
AND, OR, XOR, shifts — bit by bit, with binary laid bare.
Open tool → LiveASCII Table
Every ASCII code, character, and escape sequence.
Open tool → LiveCipher Lab
Caesar, Vigenère, and Atbash ciphers in your browser.
Open tool → LiveAnagram Solver
Find every anagram hiding in your letters.
Open tool →