The integers 1 through 9 are arranged as follows on a rectangular keypad:
$\begin{array}{c c c} 1 & 2 & 3\\ 4 & 5 & 6\\ 7 & 8 & 9 \end{array}$
Consider the 6-digit palindromes formed by going back and forth across a diagonal, row, or column of the grid. (ex: 123321, 159951, 357753, 456654, ...).
Why are all these numbers divisible by 111? In other words, what property of these numbers makes them divisible by 111? I've tried casework on whether the number is formed on a row, diagonal, or column, but haven't gotten anywhere.
In addition, can we generalize the result (keypads with different combinations of numbers that still have the above property)?
Here's the keypad :
$$\begin{array}{c c c} 1 & 2 & 3\\ 4 & 5 & 6\\ 7 & 8 & 9 \end{array}$$
Take a look at rows, columns and diagonals. What do they have in common? If you take any 3 numbers in a row, columns or diagonal, say $a\, b\, c$, then $b-a=c-b$. Let's call this difference $\epsilon:=b-a=c-b$.
Now take any palindrome formed with a column, row or diagonal, its general form is
$$P=10^5a+10^4b+10^3c+10^2c+10b+a$$ Replace $b=a+\epsilon$ and $c=a+2\epsilon$ $$\begin{array}{rcl} P&=&10^5a+10^4(a+\epsilon)+10^3(a+2\epsilon)+10^2(a+2\epsilon)+10(a+\epsilon)+a\\ &=&a(10^5+10^4+10^3+10^2+10+1)+\epsilon(10^4+2\cdot 10^3+2\cdot 10^2+10)\\ &=&111111a+12210\epsilon\\ &=&11\cdot 111\cdot 91\cdot a + 11\cdot 111\cdot 10\cdot \epsilon \end{array}$$
Both the $a$ term and the $\epsilon$ term are divisible by $111$ and $11$.
Note: $\epsilon$ can be positive or negative or even null. It can even work for $a\,b\,c$ that aren't in the keypad.