← All projects / Modulo

Round and round: modulo

Modulo means what's left over after dividing. 17 modulo 5 is 2. It sounds small, but every loop on this site is a modulo in disguise: a last digit is a number modulo 10, and a digital root is a number modulo 9. This page is about what happens when several of them run at once.

The 24-hour clock

Take any number modulo 3 and modulo 8. Modulo 3 says which trio it's in. Modulo 8 is its last three bits. Put the two together and you get the number modulo 24, which is an hour on a 24-hour clock. Modulo 1 is always 0, because everything divides by 1.

FamilyModulo 3Modulo 8HoursRows on a prime hour

Tap a family to see its hours on the clock. Filled hours are the eight where a prime bigger than 3 can land.

proved

Primes only live on eight of the hours

1, 5, 7, 11, 13, 17, 19 and 23. Every other hour shares a factor with 24, so every number on it divides by 2 or by 3.

proved

The 67s and 97s never leave the prime hours

The 97s sit on hour 1 for ever. The 67s swap between 11 and 19. Every row of both is on an hour where a prime can live, and they're the two original families richest in primes.

proved

The 1null1s lose half their rows

They swap between hour 9 and hour 17. Nothing on hour 9 can be prime, so half the family is gone before any search starts. The even families lose everything.

proved

Every prime, squared, lands on hour 1

25, 49, 121, 169, 289: all one more than a multiple of 24. Hour 1 is the 97s' hour, and the 97s contain 25 and 49.

Thinking in threes

Modulo 3 only has three answers: 0, 1 and 2. Those are exactly the digits of base 3, where you count in threes instead of tens. So a number modulo 3 is just its last digit in base 3.

A 97s numberIn base 3The power of two inside itThat power in base 3
13111411
25221822
49121116121
9710121321012
19321011642101
exact

In base 3, a 97s number is a power of two with a 1 on the end

A 97s number is 3 times a power of two, plus 1. Multiplying by 3 in base 3 just adds a 0 on the end, the way multiplying by 10 does in ordinary digits. Then the plus 1 turns that 0 into a 1. That's why the 97s are always 1 modulo 3.

exact

Base 3 swaps the two jobs

In ordinary digits the last digit is modulo 10 and the digital root is modulo 9. In base 3 the last digit is modulo 3, which is the trio, and the digital root is modulo 2, which is odd or even. So base 3 shows the trio on the surface and hides odd and even inside the digit sum.

measured

Counted in threes, every family is level

I tallied the base-3 digits of the first 3,000 numbers of the 97s, 67s, 1null1s, 0101 and 1010. In every one the digits 0, 1 and 2 each came to between 33.2% and 33.5%.

not proved

It leads straight to a famous open question

Since the 97s are powers of two in base 3, their digits are the digits of powers of two in base 3. There's an unsolved problem about exactly that: past 256, does every power of two have a 2 somewhere in its base-3 form? I checked up to 2 to the power 20,000 and the only ones without a 2 are 4 and 256. Nobody has proved it stays that way.

Counting in eights

In base 8 you count 1, 2, 3, 4, 5, 6, 7 and then roll over. So 8 itself is written 10: a 1 and a 0. Every base-8 digit stands for exactly three bits, which is why binary patterns come out so clean in it.

FamilyIts numbers in base 8What you seeLast digit
Powers of two1, 2, 4, 10, 20, 40, 100, 200, 400only ever a 1, a 2 or a 4, then zeros0
010125, 125, 525, 2525, 125252s and 5s taking turnsalways 5
101052, 252, 1252, 5252, 252525s and 2s taking turnsalways 2
000111s7, 107, 307, 707, 10707, 307077s and 0salways 7
111000s70, 1070, 3070, 7070, 1070707s and 0salways 0
1null1s11, 21, 41, 101, 201, 401a 1, 2 or 4, zeros, then 1always 1
67s13, 23, 43, 103, 203, 403a 1, 2 or 4, zeros, then 3always 3
97s15, 31, 61, 141, 301, 6013, 6 or 14, zeros, then 1always 1
null1nulls6, 16, 36, 76, 176, 376, 776a 1 or 3, then 7s, then 6always 6
exact

In base 8, the powers of two are 4, 2 and 1

Every power of two is a 1, a 2 or a 4 followed by zeros. Nothing else. Doubling just walks 1, 2, 4 and then the rollover adds a zero and starts again.

exact

21 and 42 are each other backwards

21 is 25 in base 8 and 42 is 52. The whole 0101 and 1010 families are 2s and 5s taking turns, and 2 and 5 are a mirror pair here: they add up to 7.

exact

My groups are the base-8 doubling loops

Add up digits in base 8 and double, the way the dial on the digit families page does in base 10. The loops are 1, 2, 4, then 3, 6, 5, and 7 on its own. That's my evil trio as one closed loop, 7 standing alone the way 9 does in base 10, and 8 as the rollover. In base 10 the same trio gets tangled into a loop of six with 8, 7 and 5.

exact

The last digit is the family's gate, and it never changes

The last base-8 digit is the last three bits, and every family that grows on the left keeps those fixed. So each family has one last digit for ever: 5, 2, 7, 0, 1, 3, 1 and 6. Between them they use all eight digits except 4.

exact

Digital roots loop in threes

In base 8 the digital root is the number modulo 7. For every family that grows on the left it runs in a loop of three: 1, 5, 7 for 0101, and 4, 5, 7 for the 67s. In base 10 the same families needed loops of two, six, nine or twenty-seven.

measured

Primes in base 8

Up to 100,000 the primes end in 1, 3, 5 and 7 almost equally, about 2,400 each. And the next prime repeats the last digit only 14% of the time, where chance would give 25%. It's the same reluctance to repeat that showed up in base 3.

Crossing out

A modulo family is the simplest pattern there is: a mark on every 2nd number, or every 3rd, or every 5th. Tick the boxes to cross out one family at a time and watch what's left.

Cross out multiples of

left, and primeleft, but not prime yet

proved

What's left is the primes

Cross out the multiples of 2, 3, 5, 7, 11 and 13 and every number left under 210 is prime. This is the oldest way of finding primes there is. It's about 2,200 years old.

proved

The long, not expected time

One family repeats every 2 places. Two of them together repeat every 6. Then 30, then 210, then 2,310, then 30,030. Each new family multiplies the wait, because the patterns only line up when every one of them comes round at once.

proved

Why primes never fall into a loop

Every family on this site has a last-digit loop because it's built from one or two modulos. The primes are built from all of them at once, and that pattern's repeat keeps running away. So there's no loop to find.

The prime family

That gives one more family: a 1 on every prime row and a 0 on every other row, adding one bit on the right each time, the same way as the Fibonacci family.

exact

0, 1, 3, 6, 13, 26, 53, 106...

It doubles on every row that isn't prime, and doubles and adds 1 on every row that is. Every row is about 41.47% of the power of two above it. That number is called the prime constant, and it isn't a fraction, because the pattern never repeats.

proved

Its primes can only sit on prime rows

On any other row the last bit is 0, so the number is even. Row 3 gives 3, row 5 gives 13 and row 7 gives 53: primes on prime rows, made of primes.

measured

How many it has

Its first primes are on rows 3, 5 and 7.

measured

Its digital roots are perfectly level

Over the first 10,000 rows every digital root from 1 to 9 turns up about 11% of the time. The Fibonacci family spends nine rows in ten on the doubling loop. This one shows no favourite at all.

Adding instead of crossing out

Stack every modulo family on top of the others and count how many marks land on each place. Place 12 gets six, one each from the families for 1, 2, 3, 4, 6 and 12.

exact

Each place counts its own divisors

A place gets a mark from every number that divides it. The places with just two marks are the primes: only 1 and the number itself divide them.

exact

Add them all up and you get 1.6067

As a fraction, the family that marks every 2nd place is a third, every 3rd place is a seventh, and every 4th is a fifteenth. Add the whole lot and the total settles at 1.6067. It has a name, the Erdős–Borwein constant, and it was proved in 1948 that it isn't a fraction either.

One number, 4,232 pictures

This is an old program of mine, and it's the same idea drawn. A pen moves one step at a time inside a box and bounces off the walls. Every time the step count is a multiple of the chosen number, the pen turns 15 degrees and moves one notch round the colour wheel. That's all it does.

Three rhythms at once

The turning comes round every 24 turns. The colour comes round every 360. The walls flip the pen on a beat of their own. The picture is what you get while all three drift in and out of step, and that takes far longer than any one of them.

Why a tiny change makes a new picture

Move the number by 1 and every turn happens slightly later, so the pen meets each wall at a different point. After a few bounces the path has nothing in common with the last one. That's how one rule gave 4,232 different pictures.