- Primes are colored red.
- Press & drag to pan the diagram.
How it works
- Starting with 1, the numbers spiral around a hexagon so that they're broken up into 6 rows.
- All primes other than 2 & 3 end up in rows 1 & 5.
- Numbers in rows 1 & 5 that are not prime are divisible by previously found primes, the first of which is 25 (5x5).
The code (view source)
- Start with primes 2 & 3 in hand.
- Starting at 5, increment by 2, then by 4. Repeat while adding these numbers to the possiblePrimes array.
- Multiply the numbers in the possiblePrimes array together. If the multiples exist in rows 1 or 5, add them to the multiples array.
- Compare arrays. Remove numbers from possiblePrimes if they also exist in multiples.