Home Tools Blog About

Generate Prime Numbers

In short

Generate Prime Numbers List every prime up to 10,000,000 with the Sieve of Eratosthenes. Free, offline, client-side - with density and largest-gap stats.

  • Runs in your browser
  • Nothing uploaded
  • Free, no sign-up

Generate every prime number up to 10 million using the Sieve of Eratosthenes backed by a Uint8Array. The tool reports how many primes it found, their density, and the largest gap between consecutive primes in your range.

🛡
100% PrivateNo server uploads, ever
InstantRuns in your browser
💧
No WatermarksClean output, always
🆓
Free ForeverNo accounts, no limits

How to Use Generate Prime Numbers

  1. Pick an upper limit. Any integer from 2 to 10,000,000. The input defaults to 100, so a fresh page shows the 25 primes up to 100.
  2. Choose an output separator. Comma for inline lists, newline for spreadsheet-ready output (one prime per row), space for URL-friendly strings.
  3. Click Generate Primes or press Ctrl/Cmd+Enter. For limits ≥ 500,000 the button switches to "Sieving…" briefly while the Uint8Array sieve runs.
  4. Read the primes. Every prime up to your limit appears in the output, in order, using your chosen separator.
  5. Scan the stats line. It reports π(limit) = count of primes, density as a percentage, first and last prime, largest gap between consecutive primes, and compute time in milliseconds.
  6. Change format without waiting. Switching the separator re-renders the cached prime list instantly - no fresh sieve pass.
  7. Copy or download. Copy puts the formatted list on your clipboard; Download saves a .txt report with primes, stats, and a timestamped filename.

Frequently Asked Questions

What is the Sieve of Eratosthenes?

An ancient algorithm that finds all primes up to n by iteratively marking multiples of each prime starting from 2. Every number that remains unmarked at the end is prime. For large n, sieving is much faster than trial-dividing every candidate.

What is the maximum limit for prime generation?

10,000,000. At that size the sieve allocates about 10 MB (one byte per index) and runs in 1-2 seconds on a modern laptop. Pushing higher risks allocation failures on low-memory devices.

How fast is the generation?

Very fast. Up to 100,000 it completes in a few milliseconds; up to 1,000,000 in ~30 ms; up to 10,000,000 in 1-2 seconds. The loading state only kicks in for 500k+ to give the UI a chance to repaint.

Can I use different output formats?

Yes – comma, newline, or space. Switching the separator re-renders from the cached prime array instantly, so you can toggle freely without re-sieving.

How many primes are there up to 1 million?

Exactly 78,498 – the famous value for π(10^6). Enter 1,000,000 as the limit and the stats line will confirm the count.

What does “largest gap” mean?

The largest difference between two consecutive primes in your range. For primes up to 100 the largest gap is 8 (between 89 and 97). It’s a quick way to spot prime deserts without scanning the full list.

What does the density percentage mean?

π(n)/n – the fraction of integers up to n that are prime. It drops roughly like 1/ln(n) by the Prime Number Theorem, so density falls from 25% at n=100 to about 7.85% at n=10^6.

Why would I need to generate prime numbers?

Cryptography (RSA/DH key selection), number-theory experiments, primality-test benchmarks, hash-table sizing, coding interview problems, and teaching material for algorithm classes.

Is my data secure and is this tool free?

Yes and yes. The sieve runs 100% client-side – no server call, no analytics on your input, no data retention – and the tool is free with no sign-up or usage caps.

Does this tool work offline?

Yes. After the page has loaded, every sieve runs locally in your browser. Disconnect from the internet and the tool keeps generating primes.

Keep going

Related Tools

All Number tools →

Calculate Fibonacci Numbers

Calculate Fibonacci Numbers Generate up to 5,000 Fibonacci numbers with exact BigInt precision. Free,…

Calculate Lucas Numbers

Calculate Lucas Numbers - Generate up to 5,000 Lucas numbers with exact BigInt precision.…

Calculate Prime Factors

Calculate Prime Factors Break any integer into its prime factors with a formula like…

Convert Numbers to Image

Render any number or text as a PNG / JPEG with custom font, color,…

Convert Numbers to Words

Convert numbers to English words. Cardinal, ordinal, check-writing format. BigInt for huge numbers, decimal…

Convert Words to Numbers

Convert English number words to numbers (and back). Supports negative, billions, quintillions. Free, client-side,…

Filter Numbers

Filter a list of numbers - gt, lt, eq, even/odd, positive/negative, integer/decimal, unique, between,…

Add Hex Numbers

Add Hex Numbers instantly. Free, offline, client-side tool that outputs results in both hex…

Calculate Bitwise AND of Hexadecimal Numbers

Perform bitwise AND on hexadecimal numbers instantly. Free, secure, client-side tool.

Generate Random Binary Numbers

Generate random binary numbers with configurable bit width.

Generate Random Decimal Numbers - Any Range

Generate random decimal/floating-point numbers in a range.

Generate Random Hex Numbers - Any Length

Generate random hexadecimal numbers instantly. Free, offline, client-side hex generator for developers, testers, and…

Share

Embed this tool

Add this free tool to your website. Copy and paste the code: