# Mod’s Chosen

When you divide one integer by another, one of two things happens. Either the second number goes perfectly into the first or there’s a remainder:

15 / 5 = 3
18 / 5 = 3⅗

In the first case, there’s no remainder, that is, the remainder is 0. In the second case, there’s a remainder of 3. And all that gives you the basis for what’s called modular arithmetic. It returns the remainder when one number is divided by another:

15 mod 5 = 0
16 mod 5 = 1
17 mod 5 = 2
18 mod 5 = 3
19 mod 5 = 4
20 mod 5 = 0
21 mod 5 = 1
22 mod 5 = 2...

It looks simple but a lot of mathematics is built on it. I don’t know much of that maths, but I know one thing I like: the patterns you can get from modular arithmetic. Suppose you draw a square, then find a point and measure the distances from that point to all the vertices of the square. Then add the distances up, turn the result into an integer if necessary, and test whether the result is divisible by 2 or not. If it is divisible, colour the point in. If it isn’t, leave the point blank.

Then move on to another point and perform the same test. This is modular arithematic, because for each point you’re asking whether d mod 2 = 0. The result looks like this:

d mod 2 = 0

Here are more divisors:

d mod 3 = 0

d mod 4 = 0

d mod 5 = 0

d mod 6 = 0

d mod 7 = 0

d mod 8 = 0

d mod 9 = 0

d mod 10 = 0

d mod various = 0 (animated)

You can also use modular arithmetic to determine the colour of the points. For example, if d mod n = 0, the point is black; if d mod n = 1, the point is red; if d mod n = 2, the point is green; and so on.

d mod 3 = 0, 1, 2 (coloured)

d mod 4 = 0, 1, 2, 3 (coloured)

d mod 5 = 0, 1, 2, 3, 4 (coloured)

d mod 5 = 0, 1, 2, 3, 4 (animated and expanding)

# Autonomata

“Describe yourself.” You can say it to people. And you can say it to numbers too. For example, here’s the number 3412 describing the positions of its own digits, starting at 1 and working upward:

3412 – the 1 is in the 3rd position, the 2 is in the 4th position, the 3 is in the 1st position, and the 4 is in the 2nd position.

In other words, the positions of the digits 1 to 4 of 3412 recreate its own digits:

3412 → (3,4,1,2) → 3412

The number 3412 describes itself – it’s autonomatic (from Greek auto, “self” + onoma, “name”). So are these numbers:

1
21
132
2143
52341
215634
7243651
68573142
321654798

More precisely, they’re panautonomatic numbers, because they describe the positions of all their own digits (Greek pan or panto, “all”). But what if you use the positions of only, say, the 1s or the 3s in a number? In base ten, only one number describes itself like that: 1. But we’re not confined to base 10. In base 2, the positions of the 1s in 110 (= 6) are 1 and 10 (= 2). So 110 is monautonomatic in binary (Greek mono, “single”). 10 is also monautonomatic in binary, if the digit being described is 0: it’s in 2nd position or position 10 in binary. These numbers are monoautonomatic in binary too:

110100 = 52 (digit = 1)
10100101111 = 1327 (d=0)

In 110100, the 1s are in 1st, 2nd and 4th position, or positions 1, 10, 100 in binary. In 10100101111, the 0s are in 2nd, 4th, 5th and 7th position, or positions 10, 100, 101, 111 in binary. Here are more monautonomatic numbers in other bases:

21011 in base 4 = 581 (digit = 1)
11122122 in base 3 = 3392 (d=2)
131011 in base 5 = 5131 (d=1)
2101112 in base 4 = 9302 (d=1)
11122122102 in base 3 = 91595 (d=2)
13101112 in base 5 = 128282 (d=1)
210111221 in base 4 = 148841 (d=1)

For example, in 131011 the 1s are in 1st, 3rd, 5th and 6th position, or positions 1, 3, 10 and 11 in quinary. But these numbers run out quickly and the only monautonomatic number in bases 6 and higher is 1. However, there are infinitely long monoautonomatic integer sequences in all bases. For example, in binary this sequence at the Online Encyclopedia of Integer Sequences describes itself using the positions of its 1s:

A167502: 1, 10, 100, 111, 1000, 1001, 1010, 1110, 10001, 10010, 10100, 10110, 10111, 11000, 11010, 11110, 11111, 100010, 100100, 100110, 101001, 101011, 101100, 101110, 110000, 110001, 110010, 110011, 110100, 111000, 111001, 111011, 111101, 11111, …

In base 10, it looks like this:

A167500: 1, 2, 4, 7, 8, 9, 10, 14, 17, 18, 20, 22, 23, 24, 26, 30, 31, 34, 36, 38, 41, 43, 44, 46, 48, 49, 50, 51, 52, 56, 57, 59, 61, 62, 63, 64, 66, 67, 68, 69, 70, 71, 75, 77, 80, 83, 86, 87, 89, 91, 94, 95, 97, 99, 100, 101, 103, 104, 107, 109, 110, 111, 113, 114, 119, 120, 124, … (see A287515 for a similar sequence using 0s)