# Deleting a Digit

Find the number of 5-digit positive integers n that have the following property: If we delete any digit in n, then we get a 4-digit number which is always divisible by 7. I did a little bit of modular arithmetic, but things got nasty. P.S:31,16 are wrong.(It's not that easy). I think the answer is 2

• I would just program it. – Yuval Filmus Feb 9 '15 at 5:36

Suppose $abcde$ is such a number. In particular, $abcd$ and $abce$ are both divisible by $7$, so that $d\equiv e \pmod{7}$. Similar reasoning shows that in fact all of the digits are equivalent modulo $7$.

What should they be equivalent to? $1111 \pmod{7} = 5$, so $a,b,c,d,e$ must all be equivalent to $0$ modulo $7$. This gives us $2^5=32$ numbers, since each digit can be either $0$ or $7$. Actually only $31$ of these are positive.

• Corroborated with a computer search. – Yuval Filmus Feb 9 '15 at 5:43
• Also, a (conventionally) five-digit integer can't start with a zero, so it has to start with a seven, reducing it to only $2^4 = 16$ suitable integers. – kate Feb 9 '15 at 5:51
• @kate ...and if you extend the requirement that the 4-digit, 3-digit, and 2-digit numbers must also not begin with $0$, no matter which digit you delete at each stage, you are left with only 2 options: $77777$ and $77770$. – Joffan Feb 9 '15 at 6:31
• @Garvil There is more than one correct answer, since there is more than one interpretation of the question. In all cases, the solution is what I wrote. – Yuval Filmus Feb 9 '15 at 15:16
• @Joffan - it only speaks of deleting one digit to get a 4-digit number. So it only requires that the first two digits are both 7, thus giving 8 options. – Glen O Feb 12 '15 at 6:55

Well, I solved my own question(that too with a bounty by me!). So here it is- Let the number be $abcde$. By the given property, $bcde$ and $acde$ are divisible by $7$. But then their difference $bcde−acde=1000(b−a)$ must be divisible by $7$, which means $b−a$ is divisible by $7$. In other words, $$a≡b(mod7)$$Considering other pairs of numbers, we also get $$b≡c(mod7)$$$$c≡d(mod7)$$$$d≡e(mod7)$$ so $$a≡b≡c≡d≡e(mod7)$$ Then $abcd≡1111a≡0(mod7)$. Since $1111$ is relatively prime to $7$, $a≡0(mod7)$, so each digit must be $0$ or $7$. The digit $a$ must be $7$, and the digit $b$ must be $7$ (since $bcde$ must be a 4-digit number), but then $c, d, e$ can be set to $0$ or $7$ arbitrarily, which gives us $2^3=8$ possible numbers.

• I will likely verify this soon. I like this question. – user142198 Feb 12 '15 at 0:19