← All projects / The Counters

Counters with lanes of different sizes

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.

How to read one

The count

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.

The green lamps: anything in the lane?

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.

The orange lamps: is the lane full?

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.

Naming a counter

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.

Run a counter

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.CountNot emptyFull

The primes on this counter

Orange patterns the primes land on most

Full lanesPrimesShare of primesShare of allowed numbers

Green patterns the primes land on most

Lanes not emptyPrimesShare of primesShare of allowed numbers

A rule from the lamps

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.

The counters asked for

exact

4 2 1

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.

exact

3 6 9 from the right (written 9 6 3)

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.

exact

3 6 9 as written

Now the right-hand lane holds ten values, so it's just the ordinary last digit. Same lane sizes, same blindness to 3.

exact

...8 4 2 1 8 4 2 1, for ever

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.

exact

Fibonacci tops: ...8 5 3 2 1

Each lane's top is the next Fibonacci number.

exact

The primes as tops: ...7 5 3 2

exact

8 4 2 1 and 9 6 3 added together

Lane by lane, the two tops are added: 1 + 3, 2 + 6, 4 + 9, 8 + 3 and so on.

Reading the lamps as a number

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 inFirst lampsSecond lampsLamp numberThe nth prime
proved

The lamps can't keep up with the primes

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.

measured

How often a lamp number is 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.

proved

Some primes can never be made by an overlay

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.

How many steps to make each prime

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.

PrimeIn binarySteps until the green lamps show itSteps until the orange lamps show it
proved

The step count has an exact formula

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.

exact

But the formula needs the prime 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.

exact

Are these sequences known?

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.

Base 6 and base 7, side by side

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.

CountIn base 6In base 7Green lamps, addedOrange lamps, addedBase 6 digits read as base 7

Shaded rows are prime counts. Lamp numbers are base 6 first, then base 7.

exact

They part company at 6

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.

measured

Adding their lamps doesn't give the primes

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.

exact

Base 7 with the 6 switched off

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).

measured

Primes in, primes out?

measured

What does matter is the count's remainder by 5

Every way of combining the two

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.

Green rule: 1 means the lane isn't empty

Combined byFirst twelve numbersDifferent numbers madeRangeShare that are primePrimes it can make

Orange rule: 1 means the lane is full

Combined byFirst twelve numbersDifferent numbers madeRangeShare that are primePrimes 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.

measured

The mix with the most primes is a mirage

exact

Minus each way is one list, mirrored

measured

Green keeps lamps lit, orange keeps them dark

measured

Stacking reaches furthest but skips the most

exact

What decides the prime share

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.

A family's clues as a counter

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 laneSwitched-off slotThis power sits on
measured

Nearly half the primes have no switched-off slot

proved

The 97s' slots are the 67s' slots counted backwards

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.

measured

How much the lanes rule out

exact

What the clues give

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.

More things the counters show

proved

Twin primes sit either side of a double carry

proved

Orange is green in a mirror

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.

measured

Two counters together know more than either alone

measured

How many lanes roll over next says nothing

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%.

A full turn, and the step after it

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.

LanesBiggest lane primeEvery lane fullIs it prime?One step laterIs it prime?
235prime7prime
3529prime31prime
4720911 × 19211prime
5112,309prime2,311prime
61330,029prime30,03159 × 509
717510,50961 × 8,369510,51119 × 97 × 277
8199,699,68953 × 197 × 9299,699,691347 × 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.

Which counter is best for primes?

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.

CounterLane sizes, from the rightRepeats afterPrimes it can seeNumbers left standing
proved

A counter sees a prime only if a lane size divides by it

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.

proved

The best counter uses the primes themselves as lane sizes

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.

proved

All orange lit means one short of a full turn

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.

measured

The lamps don't know more than the lanes do

What a counter gives, and what it doesn't

It gives

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.

It doesn't give

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.