Skip to main content
Z

Sieve of Eratosthenes Visualizer — Find Primes

Animated Sieve of Eratosthenes on a number grid — marks primes and crosses out composites, with step controls. Runs in your browser.

Free No signup Client-side Privacy friendly Updated

/

Pseudocode

Run an operation to see its steps.

How to use

  1. 1 Type a limit n (up to 150) and press Run sieve.
  2. 2 Watch each prime get marked, then cross out all of its multiples as composite.
  3. 3 Step back and forward, or use Random for a different limit.
  4. 4 Green cells are prime, grey cells are composite.

Why use this tool

  • See why the sieve only needs to start marking from p² for each prime p.
  • Watch composite numbers fall away, leaving the primes highlighted.
  • Understand the near-linear O(n log log n) running time.
  • Runs entirely in your browser. No signup, no uploads.

Frequently asked questions

What is the Sieve of Eratosthenes?

An ancient algorithm for finding all prime numbers up to a limit n: repeatedly take the next unmarked number (a prime) and mark all of its multiples as composite.

What is the time complexity of the sieve?

O(n log log n) time and O(n) space — far faster than testing each number for primality individually.

Why does marking start at p² instead of 2p?

Every multiple of p smaller than p² (like 2p, 3p, …) already has a smaller prime factor and was marked when that smaller prime was processed, so starting at p² avoids redundant work.

Is 1 a prime number?

No. 1 has only one divisor, so by definition it is neither prime nor composite — the sieve treats it as a non-prime.

What is Sieve of Eratosthenes Visualizer?

A Sieve of Eratosthenes Visualizer animates the classic prime-finding algorithm: starting at 2, it marks each unmarked number as prime and crosses out all of its multiples as composite, leaving only the primes up to n.

Features

Step-by-step animation

Watch multiples of 2, 3, 5, … get crossed out, leaving the primes.

Complexity

Time: O(n log log n). Space: O(n) for the boolean sieve.

100% private

Runs entirely in your browser — nothing is uploaded.

Example

Input

primes up to 30

Output

2, 3, 5, 7, 11, 13, 17, 19, 23, 29

Common use cases

  1. 1

    List primes fast

    Generate all primes below a limit efficiently.

  2. 2

    Precompute for problems

    Build a prime table for number-theory or competitive problems.

  3. 3

    Learn the sieve idea

    See why marking multiples beats per-number primality tests.

Summary

Zerethon's Sieve of Eratosthenes visualizer animates finding all primes up to a limit n in your browser, marking the multiples of each prime as composite. The sieve runs in O(n log log n) time and O(n) space — far faster than testing each number individually.

Category
Algorithm
Pricing
Free
Privacy
Browser-based
Signup
Not required

References

Privacy

Your data never leaves your browser unless explicitly stated. Sieve of Eratosthenes Visualizer runs entirely client-side — no server upload, no logging, no tracking of your input.

New to this? Read the step-by-step explanation with Big-O analysis: Learn Number Theory →

Related tools

Build, share, and grow on Zerethon Social

Free signup. Earn points, collect achievements, and connect with creators worldwide.

Sign up free