## Divisible by 7

How many four digit positive integers divisible by $7$ have the property that, when the first and last digits are interchanged, the result is a (not necessarily four-digit) positive integer divisible by $7$?
Source: NCTM Mathematics Teacher, October 2006

Solution
Is $8673$ divisible by $7$? One way to find out is by determining if $8673$ “behaves” like $7$ or $14$ or some other small multiples of $7$. Modulo $7$ arithmetic will help us do that. In its most basic definition, modulo arithmetic is the arithmetic of remainder. We say “$8$ is congruent to $15$ modulo $7$” and write $8\equiv 15\bmod 7$, because $8$ and $15$ yield the same remainder when divided by $7$.
Using $8673=8(1000)+6(100)+7(10)+3(1)$, we will do the same calculation but with congruent numbers mod $7$. For ease in presentation we drop the modulo $7$ notation.
Since $1000\equiv 6,100\equiv 2,10\equiv 3,8\equiv 1,7\equiv 0$,
$8(1000)+6(100)+7(10)+3(1)\equiv 1(6)+6(2)+0(3)+3(1)$
$\equiv 6+12+0+3\equiv 21$
$8673$ is divisible by $7$.

Let $axy\,b$ be a 4-digit positive integer where the digits are $a,x,y$, and $b$. Suppose $7$ divides $axy\,b$ and $bxya$. Show that $7$ divides $(a-b)$.
Since $7$ divides $axy\,b$ and $bxya$, there exist integers $k_1$ and $k_2$ such that
$a(1000)+x(100)+y(10)+b=7k_1\qquad\qquad (1)$
$b(1000)+x(100)+y(10)+a=7k_2\qquad\qquad (2)$
Subtract Eq. $(2)$ from Eq. $(1)$
$(a-b)1000+(b-a)=7k_3$ where $k_3=k_1-k_2$
$1000a-1000b+b-a=7k_3$
$999(a-b)=7k_3$
In other words, $7$ divides $999(a-b)$. Since $7$ does not divide $999$, $7$ must divide $(a-b)$.

Show that if $7$ divides $axy\,b$, then $7$ divides $10x+y$.
Given $a(1000)+x(100)+y(10)+b=7k_4$ for some integer $k_4$,
$1000a+100x+10y+b=7k_4$
$1001a-a+100x+10y+b=7k_4$
$1001a-(a-b)+100x+10y=7k_4$
Since $7$ divides $1001a$ and $(a-b)$, $7$ must divide $100x+10y$. Hence, $7$ divides $10x+y$.

We have two cases to consider: $a=b$ and $a\neq b$.
Case 1: $a=b$
The integers are of the form $axy\,a$ where the $xy$ numbers are divisible by $7$. The $15$ possible $xy$ numbers are: $00,07,14,21,28,35,42,49,56,63,70,77,84,91,98$. The $9$ possible $a$ digits are: $1,2,3,4,5,6,7,8,9$. There are $9\times 15=135$ possible $axy\,a$.
Cases 2: $a\neq b$
The integers are of the form $axy\,b$ where digits $a$ and $b$ are congruent. Interchanging congruent digits like $0$ and $7$, $1$ and $8$, $2$ and $9$ has no bearing on the remainder. The $5$ possible $axy\,b$ are: $1xy8,8xy1,2xy9,9xy2,7xy0$. There are $5\times 15=75$ possible $axy\,b$.
Total number of integers equals $135+75=210$.
List of some of the integers
$1001,1008,1071,1078,1141,1148,1211,1218,1281,1288,1351,1358,1421,1428,1491,1498$
$\cdots$
$7000,7007,7070,7077,7140,7147,7210,7217,7280,7287,7350,7357,7420,7427,7490,7497$
$\cdots$
$9002,9009,9072,9079,9142,9149,9212,9219,9282,9289,9352,9359,9422,9429,9492,9499$

Answer: $210$