piapia123
en

Prime Numbers

Generators

Everything runs locally in your browser — nothing is uploaded

Output

Five things share one tool because underneath they are the same kernel: deciding whether a number is prime. “What is the thousandth prime”, “which primes lie between 100 and 200” and “give me ten random primes” are all that kernel with a different surface. Split across five pages, the primality test would be written five times, and it is precisely the part that must not be got wrong. Testing uses Miller-Rabin, not trial division to the square root. Trial division is fine for ten-digit numbers and hopeless for eighteen-digit ones — a billion divisions, and the page locks up. Miller-Rabin is probabilistic, but with a fixed set of bases it is deterministic over a bounded range: using the first twelve primes as bases, no composite below 3.3×10²⁴ can pass (that bound is proven). Above it, the tool says plainly that the verdict is probabilistic. Factorisation uses Pollard rho with deterministic parameters: the polynomial constant is tried from 1 upwards and no randomness is involved, so the same input always takes the same path. Numbers too large to factor are refused outright rather than spinning for minutes and looking like a dead page.

Features

  • Five modes: test, factorise, Nth prime, range and random generation
  • Miller-Rabin testing: milliseconds even at eighteen digits, with no trial division to the root
  • Verdicts below 3.3×10²⁴ are deterministic; above that the tool marks them probabilistic
  • Prime factorisation via Pollard rho, which splits the product of two large primes
  • A failing test reports the smallest prime factor so you can check it
  • Factorisation lists each prime with its exponent (`2^3 × 3^2 × 5`), each copyable
  • Carmichael numbers — the composites that fool Fermat’s little theorem — are caught
  • Ranges list up to 500 primes, and say how many were left out
  • Everything runs on your machine with no external service

How to use

  1. Choose a mode: test, factorise, Nth prime, range or random
  2. Fill in the corresponding value (range and random modes need a range)
  3. The result appears as you type; copy a single row with its button

FAQ

What does “probabilistic” mean here? Can it be wrong?
Miller-Rabin is probabilistic, but with a fixed set of bases it has no counterexamples within a bounded range — it is proven that with the first twelve primes (2 to 37) as bases, no composite below 3.3×10²⁴ can pass as prime. So within that range the verdict is deterministic. Above it the test is still extremely reliable (error probability below 4⁻¹²), it is just no longer a proof, and the tool says so.
How large a number can be factorised?
The limit is eighteen digits. Factorisation combines trial division by small primes, Pollard rho and Miller-Rabin, and the product of two large eighteen-digit primes (about 60 bits) usually resolves within a second. Past that the tool refuses and explains, rather than spinning for minutes — a page that stops responding is far worse than a sentence saying the number is too big.
Why is the first prime 2 rather than 1?
Because 1 is not prime by definition (a prime has exactly two positive divisors and 1 has only one). So the first prime is 2 and the sequence runs 2, 3, 5, 7, 11… This tool also says plainly that 0 and 1 are not prime, and does not add a note about their “smallest prime factor” — there is none, and such a note would be wrong.

Related tools