← All projects / The Counters
An ordinary counter gives every place the same size: ten in decimal, two in binary. These counters give each lane its own. The 4 2 1 counter has a lane that fills at 1, a lane that fills at 2 and a lane that fills at 4. This page runs them and checks what each one shows about the primes.
The right-hand lane moves fastest. When a lane is full, the next step empties it and adds one to the lane on its left, like a car's mileage dial with wheels of different sizes. On 4 2 1 the count runs 0, 1, 10, 11, 20, 21, 100. Mathematicians call this a mixed radix count.
A lane's green lamp is lit when the lane isn't empty. In electronics that's a nonzero flag. 20 lights the left lamp only. 21 lights both.
A lane's orange lamp is lit only when the lane is at its top value. In electronics that's the terminal count, the signal a counter gives just before it carries. 21 lights both. 11 lights the right lamp only.
A counter is named by the top value of each lane, written the way the count is read. So 4 2 1 has tops of 1, 2 and 4 going from right to left. "3 6 9 from the right" is written 9 6 3.
Type tops with spaces between them, like 10 6 4 2 1. A run of single digits works too, like 8421.
lane isn't emptylane is fulllamp offshaded row: a prime
| No. | Count | Not empty | Full |
|---|
| Full lanes | Primes | Share of primes | Share of allowed numbers |
|---|
| Lanes not empty | Primes | Share of primes | Share of allowed numbers |
|---|
Keep a number only when enough lamps are lit, and see how many of the kept numbers are prime. A full lane is never empty, so an orange lamp always has a green one with it.
"Allowed numbers" are all the numbers up to 100,000 that the counter can't rule out: the ones that don't divide by any prime it can see. If the lamps knew something extra about primes, the two share columns would disagree.
Its lanes hold 2, 3 and 5 values, the first three primes. That makes it a known system, the primorial count, and it's the most efficient counter there is for its size.
Its lanes hold 4, 7 and 10 values. Those sizes divide by 2, 5 and 7 but never by 3, so this counter is blind to multiples of 3.
Now the right-hand lane holds ten values, so it's just the ordinary last digit. Same lane sizes, same blindness to 3.
The lanes hold 2, 3, 5 and 9 values, over and over. However many lanes are added, the sizes only ever divide by 2, 3 and 5.
Each lane's top is the next Fibonacci number.
Lane by lane, the two tops are added: 1 + 3, 2 + 6, 4 + 9, 8 + 3 and so on.
Feed a count into a counter, then read its row of lamps as a binary number: lit is 1, off is 0. Two counters can be overlaid by feeding both the same count and adding their lamp numbers. The idea to test: feed in n, and see whether the lamps give the nth prime, or any prime.
| Count fed in | First lamps | Second lamps | Lamp number | The nth prime |
|---|
A lane gives one lamp, so one bit. But a lane holds more than two values, so the count runs ahead of the lamps. After 100,000 steps the lamps of ...8 4 2 1 have only reached 511. The 100,000th prime is 1,299,709. Adding two, three or four lamp numbers doesn't close a gap that size, so past the first couple of counts no mix here can equal the nth prime.
Across fourteen single counters and eight overlays, between 9% and 50% of lamp numbers were prime. Two things decide it: how often the right-hand lamp is lit (that makes the number odd) and how small the numbers stay. The line under the tool shows that sum for whatever you pick.
Adding the green lamps of ...8 4 2 1 and ...9 6 3 never gives 5, 11 or 79, however long the counters run. A small lamp number needs a small count, and I tried every count small enough.
Turn the idea round. Pick a prime, and ask how many steps the counter needs before its lamps first show that prime in binary. This uses the first counter chosen above.
| Prime | In binary | Steps until the green lamps show it | Steps until the orange lamps show it |
|---|
Every prime can be made on a counter with enough lanes, and the number of steps is exact. On ...8 4 2 1 the lanes are worth 1, 2, 6, 30 and 270. 13 is 1101 in binary, so it takes 1 + 6 + 30 = 37 steps. For orange, each lane has to be full, so multiply each worth by the lane's top first.
The step count is the prime's own binary digits read in the counter's place values. It's a translation of the prime, and it works the same for every number that isn't prime: 15 is 1111, so it takes 1 + 2 + 6 + 30 = 39 steps. The steps grow fast because the lanes do, not because of anything about primes.
Partly. "Read a number's binary digits in the primes counter" is in the public sequence database as A276156. The green lamp number for a counter with tops 1, 2, 3, 4, 5 is there as A275727. I didn't find the lamp numbers for ...8 4 2 1, the primes counter or the Fibonacci tops, or the step counts for the primes alone. Not finding them isn't proof they're new.
Two plain counters, one with lanes of 6 and one with lanes of 7, each given one more step at a time. Think of both as having seven slots in a lane, with the last slot of the base 6 counter always switched off. There are two ways to read what they produce.
| Count | In base 6 | In base 7 | Green lamps, added | Orange lamps, added | Base 6 digits read as base 7 |
|---|
Shaded rows are prime counts. Lamp numbers are base 6 first, then base 7.
From 1 to 5 the two counters show the same thing. At 6 the base 6 counter carries to 10, while the base 7 counter shows a 6: its lane is full, so its orange lamp lights. The right-hand lanes line up again every 42 steps.
The green lamps added together run 2, 2, 2, 2, 2, 3, 5, 6, 6, 6, 6, 5. After 100,000 steps they've only reached 190, and 8.8% of the values are prime, about what small numbers that are odd a quarter of the time would give. The lamp-number tool above has both counters if you want to try other mixes.
Write the count in base 6, then read those digits as base 7. That gives 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 14: every number that has no 6 in base 7. This list is known (A037470), and it has a real special property. It's the list you get by always taking the next smallest number that doesn't complete seven equally spaced numbers (A020657).
The same count goes into both counters, and their lamp numbers are combined ten ways: added, subtracted each way, compared lamp by lamp with xor, and, or and if, and stacked one above the other each way. Once using the green rule (a lane counts as 1 when it isn't empty) and once using the orange rule (a lane counts as 1 only when it's full). Counts run from 1 to 100,000.
| Combined by | First twelve numbers | Different numbers made | Range | Share that are prime | Primes it can make |
|---|
| Combined by | First twelve numbers | Different numbers made | Range | Share that are prime | Primes it can make |
|---|
"Primes it can make" counts the primes up to the biggest number that mix reaches. "6 above 7" writes the base 6 lamps to the left of the base 7 lamps and reads the lot as one binary number. "If 6 is lit, 7 must be" gives a 1 in every lane except where the base 6 lamp is lit and the base 7 lamp isn't.
The same two things every time: how often the right-hand lamp ends up lit, which makes the number odd, and how small the numbers stay. None of the twenty mixes puts the primes in order or picks them out ahead of other odd numbers the same size.
The families already say which numbers are switched off: every small prime rules out some of a family's powers, on a fixed cycle. That makes a different kind of counter. Each small prime gets its own lane. The lane goes round that prime's cycle and has one slot switched off. A power can only give a prime when no lane is sitting on its switched-off slot.
| Lane (prime) | Slots in the lane | Switched-off slot | This power sits on |
|---|
Lane 5 has four slots: the 67s have slot 1 off and the 97s have slot 3 off. Lane 7 has three: 2 and 1. Lane 11 has ten: 3 and 7. In every lane the two add up to the lane's length. That's the two families being mirror images, seen one lane at a time, and it's why both families are blind to the very same primes.
They say exactly where a prime can't be, and they're the 60-hour clock drawn one lane at a time. Among the powers that pass every lane, the clues don't pick a winner: every known prime passes them, and so do thousands of powers that aren't prime.
Take a count and its opposite number, the one the same distance from the end of the counter's turn. A lane that's full for one is empty for the other. So the orange row of a count is the green row of its opposite, with every lamp flipped. I checked every count on five counters. The two lamp rules carry the same information.
On the primes counter I counted how many lanes are full at the right-hand end, which is how many roll over on the next step. For numbers the counter allows it's one lane 50.0% of the time, two 37.5%, three 10.4%. For primes it's 49.9%, 37.6%, 10.5%.
On the primes counter, every lane full means the number is one short of a full turn. One step later every lane is empty and a new lane starts. That next number can't divide by any prime the counter has a lane for, because every one of those lanes has just reset. So it's either a new prime or built from new primes. This is the oldest proof that the primes never run out, from about 300 BC.
| Lanes | Biggest lane prime | Every lane full | Is it prime? | One step later | Is it prime? |
|---|---|---|---|---|---|
| 2 | 3 | 5 | prime | 7 | prime |
| 3 | 5 | 29 | prime | 31 | prime |
| 4 | 7 | 209 | 11 × 19 | 211 | prime |
| 5 | 11 | 2,309 | prime | 2,311 | prime |
| 6 | 13 | 30,029 | prime | 30,031 | 59 × 509 |
| 7 | 17 | 510,509 | 61 × 8,369 | 510,511 | 19 × 97 × 277 |
| 8 | 19 | 9,699,689 | 53 × 197 × 929 | 9,699,691 | 347 × 27,953 |
Every factor in the table is bigger than the biggest lane prime on its row, as the argument says it must be. Up to 6 lanes most of these are prime. Beyond that they mostly aren't: from 7 lanes to 15, only two of the eighteen numbers are prime.
A counter rules a number out when one of its lanes shows it divides by a small prime. The fewer numbers left standing, the better the counter.
| Counter | Lane sizes, from the right | Repeats after | Primes it can see | Numbers left standing |
|---|
Lanes of 4, 7 and 10 see 2, 5 and 7. Lanes of 2, 3, 5 and 9 see 2, 3 and 5, and the lane of 9 adds nothing new because 9 is 3 × 3. Repeating the same lane sizes for ever never adds a prime.
Lanes of 2, 3, 5, 7, 11 and so on: tops of 1, 2, 4, 6, 10. Every new lane sees a new prime and nothing is wasted. 4 2 1 is the start of it.
When every lane is full the next step empties them all. So the number is one less than a multiple of the counter's cycle: 29, 59 and 89 on 4 2 1.
A picture of the sieve. Each lane is one small prime's cycle, and the endings a prime can have are the ones no lane rules out.
Which of the allowed numbers are prime. On every counter here, the primes are spread over the lamp patterns the same way all the allowed numbers are.