[Math] Any rectangular shape on a calculator numpad when divided by 11 gives an integer. Why

divisibilityelementary-number-theory

I have come across this fact a very long time ago, but I still can't tell why is this happening.

Given the standard calculators numpad:

7 8 9
4 5 6
1 2 3

if you dial any rectangular shape, going only in right angles and each shape consisting of 4 points, then the dialed number is always divisible by 11 without a remainder.

Examples of the shapes: 1254, 3179, 2893, 8569, 2871, and so on. It is not allowed to use zero, only digits 1..9.

UPDATE: The part of the question below proved to be an error on my part because I did not double-check what the Programmers calculator was showing, and it turned out that it was rounding the results. !!! See the accepted answer for an interesting follow-up to this, which actually expands the usecase to a working hexadecimal "keypad", and the other answers for even more various interesting approaches, discovering different aspects of this problem !!!

The same rule also works even for the Programmer calculator layout on MS Windows 10 which looks like this:

A B 7 8 9
C D 4 5 6
E F 1 2 3

All valid rectangular shapes, for example, A85C, E25C, 39BF, and so on, being divided by 11 still give an integer result!

Initially I was thinking that it's just somehow tied to picking digits from the triplets and being just another peculiarity of the decimal base and number 11 and started looking this way, but discovering that it works for the hexidecimal base and even with the hex part of the keyboard layout not obeying exactly the pattern of the decimal part layout, I'm lost.

What law is this fun rule based on?

Best Answer

Since you are concerned only with rectangular patterns, you have four digit numbers in a certain base $l$, and you want to check divisibility by $11$, where $11 = l+1$.


When you have a four digit number in base $l$, write it as $al^3 + bl^2 + cl + d$, where $0 \leq a,b,c,d < l$. (This represents the $l$-base number $\overline{abcd}$). Now, we have a cute fact : $l^3 + 1$ is a multiple of $l+1$, since $l^3+1 = (l^2 - l + 1)(l+1)$. Furthermore, $l^2 - 1 = (l-1)(l+1)$. Therefore, we make the following rewrite : $$ al^3 + bl^2 + cl + d = a(l^3 + 1) + b(l^2 - 1) + c(l+1) - (a - b + c - d) \\ = (l+1)(...) + ((b+d)-(a+c)) $$

where $l+1 = 11$ in base $l$.

Therefore, the remainder when $\overline{abcd}$ is divided by $11$ is $(b+d) - (a+c)$.


When you consider four numbers ($1 \to 9$, since I found problems in the letters for hex) in a rectangle and form a four digit number out of them now, can you see why this number $(b+d) - (a+c)$ is in fact zero, therefore giving your desired result?


Now that we have pointed out this rectangular pattern, I noted above that some counterexamples did exist for the MS - layout of hexadecimal numbers. The issue there was a fairly simple one : the "matrix" of entries did not satisfy the property that $a+d = b+c$ for $a,b,c,d$ going CW/CCW around any $2\times 2$ subrectangle of entries of the matrix.

If $l-1$ is not a prime, then we can actually arrange a "matrix" of $l$ entries which is not strictly column or row, but satisfies this "rectangle property" as we can call it. For this, write $l-1 = ab$ where $a,b \neq 1$, and arrange an $a \times b$ matrix of entries, which we fill in the following fashion : start with $1$ in the bottom corner, proceed towards right filling $2,3,...$ until you hit the end, then return to the left of the row above, and fill the next number, now repeat till you fill the whole matrix.

For $10$, this procedure yields the conventional keyboard pattern. For $15 = 5 \times 3$, it would yield $$ \begin{pmatrix} B&C &D & E& F\\ 6&7&8&9&A\\ 1&2&3&4&5 \\ \end{pmatrix} $$

which indeed will satisfy the property that any rectangle has $11$ in that base as a divisor. For example, $A8DF$, $1496$ and $CE97$ are all multiples of $11$.

Note that more is true : in fact, every parallellogram , read CW or CCW, leads to a multiple of eleven.