Primality test, factorisation, next and previous primes. Free, private, runs in your browser.
100% private — your files never leave your browser. All processing happens locally on your device.
2,147,483,647 is prime ✓
Previous prime
2,147,483,629
Next prime
2,147,483,659
A prime is an integer greater than 1 whose only positive divisors are 1 and itself. 2, 3, 5, 7, 11, 13 are the first few. Every other integer greater than 1 can be written uniquely as a product of primes (the fundamental theorem of arithmetic), which is why primes are called the building blocks of the integers. Cryptography, hashing, number theory, and plenty of practical algorithms rely on properties of primes.
For numbers up to about 2^53 (JavaScript's safe-integer limit), Miller-Rabin with a small carefully-chosen witness set is provably deterministic — it gives the exact right answer every time, not just a probabilistic guess. The witnesses {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37} have been shown to correctly classify all integers below ~3.3×10^24, which more than covers the 2^53 input range. So when the tool says 'prime', it's not 'probably prime' — it's genuinely prime.
For composites, the tool shows the prime factorisation — the set of primes (with multiplicities) whose product equals the input. 360 = 2^3 · 3^2 · 5, for instance. Method: trial division up to √n, which handles the huge majority of factorisation queries in milliseconds. For the full 2^53 range the worst case (a product of two close primes) takes a few hundred milliseconds; for normal use, instantaneous.
Twin primes are pairs differing by 2 — (3, 5), (11, 13), (17, 19), (29, 31), and so on. The tool flags when your input is part of a twin pair. Also shown are the next prime after and the previous prime before your input, for quick reference when you need nearby primes (common in algorithm selection for hash table sizes, for instance).
Primality testing doesn't need a server — the algorithm runs fine in the browser. No values are transmitted, no query logs. Check as many numbers as you like, including any that you'd rather not expose to a third-party service.
Small numbers are checked by trial division against the first 25 primes. Larger numbers go through a deterministic Miller-Rabin test with a 12-witness set that's proven correct for all integers below ~3.3×10^24. Comfortably covers every JavaScript safe-integer input (up to 2^53 − 1).
Trial division up to √n. For typical inputs (up to millions or billions), results are instant. For the largest safe integers the factorisation can take a few hundred milliseconds in the browser. For cryptographic-scale factorisation you'd need dedicated tooling — but that's not what this is for.
A prime that differs by 2 from another prime — e.g. (11, 13), (17, 19), (29, 31). The twin prime conjecture (still unproven) asserts there are infinitely many such pairs. The tool flags when your input is part of a known twin pair.