Prime Numbers

Generate prime numbers in a range, check if a number is prime (with factorisation), or find the Nth prime — up to 1 000 000.

Runs locally
Primes

What is a prime number?

A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself: 2, 3, 5, 7, 11, 13… They are the fundamental building blocks of all integers through the Unique Factorization Theorem (every integer factors uniquely into primes). Primes are critical in cryptography — RSA encryption relies on the difficulty of factoring the product of two large primes. There are infinitely many primes (proved by Euclid ~300 BCE), yet they become rarer as numbers grow.

How to use this tool

  1. 1 In Generate mode, set a From and To range (up to 1 000 000) and get all primes in that range.
  2. 2 In Check mode, enter any number to see if it is prime — composite numbers also show their prime factorisation.
  3. 3 In Nth Prime mode, enter N to get the Nth prime (up to the 78498th, which is 999983).
  4. 4 Toggle comma-separated output in Generate mode to paste the list into code.

Frequently asked questions

How is the generation implemented?

The Sieve of Eratosthenes — one of the oldest known algorithms. It marks all multiples of each prime starting from 2. For a limit of 1 million, it runs in tens of milliseconds in the browser.

Is 1 a prime number?

No. By the modern definition, primes must be greater than 1. The number 1 is neither prime nor composite — it is a unit. Excluding 1 makes the Unique Factorization Theorem work cleanly.

Why is 2 the only even prime?

Every even number greater than 2 is divisible by 2, so it has at least three divisors (1, 2, itself) and cannot be prime. 2 is the unique exception because it divides itself with no other factor.

What is the largest prime this tool can find?

999983 — the largest prime below 1 000 000. The limit is set by browser memory; a Uint8Array sieve of 1 million entries uses only 1 MB.

Is anything sent to a server?

No. The sieve runs entirely in your browser.