04 Try it yourself Interactive

Strike the composites, then shrink a pair

Two runs share one console. The sieve is the same 2-to-30 grid from section 02: each press either picks the next prime, skips a p that is already crossed out, or strikes one multiple, and the line of code responsible lights up beside it. Watch for the crosses that land on a number twice — that is the redundancy the start is fighting. Switch to Euclid and the same Next button reduces 30 and 18 one division at a time until the remainder hits zero.

Sieve of Eratosthenes
strike multiples while p*p <= N
One whole number from 6 to 60.
Press Next to begin. Each press advances the run by one step.


      
Prime p
Striking
Primes found0
Crosses written0
step 0 / 0