# Divisibility by 7 involving grouping and alternating sum [closed]

Prove Number in decimal representation $N=abc,def,ghi,\cdots ,xyz$ is divisible by $7$. Iff $abc-def+ghi-\cdots+xyz$, alternating sum of numbers formed by dividing the string $N$ into $3$ digit pairs of consecutive digits. Is divisible by $7$.

## closed as off-topic by Théophile, Namaste, Leucippus, Rolf Hoyer, ShaileshNov 20 '17 at 2:24

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Théophile, Namaste, Leucippus, Rolf Hoyer, Shailesh
If this question can be reworded to fit the rules in the help center, please edit the question.

• Works for 13 too. – Oscar Lanzi Nov 19 '17 at 22:23

## 2 Answers

Let $N=\sum_{i=0}^{3n-1} a_i\cdot 10^{i}$. Since $10^3+1$ is divisible by $7$, modulo $7$ for each $k$ we have $$a_{3k+2}\cdot 10^{3k+2}+a_{3k+1}\cdot 10^{3k+1}+a_{3k}\cdot 10^{3k}\equiv$$ $$(a_{3k+2}\cdot 100+a_{3k+1}\cdot 10+a_{3k})\cdot 10^{3k}\equiv$$

$$(a_{3k+2}\cdot 100+a_{3k+1}\cdot 10+a_{3k})\cdot (-1)^{k},$$

which implies the required claim.

• $(-1)^k$ at the end, I guess – Peter Franek Nov 19 '17 at 22:05
• @PeterFranek Thanks, corrected. – Alex Ravsky Nov 19 '17 at 22:07

Note that $7$ divides $10^{3(2n+1)}+1$ and $10^{3(2n)}-1$, this is easy to see by Fermat \begin{eqnarray*} 10^{6n} \equiv 1 \pmod{7} \\ 10^{6n+3} \equiv -1 \pmod{7}. \end{eqnarray*} So $7 \mid 10^{3n} a_n b_n c_n + 10^{3(n-1)} a_{n-1} b_{n-1} c_{n-1} +\cdots +10^{3} a_1 b_1 c_1 + a_0 b_0 c_0$ if and only if $7 \mid (-1)^{n} a_n b_n c_n + (-1)^{n-1} a_{n-1} b_{n-1} c_{n-1} +\cdots - a_1 b_1 c_1 + a_0 b_0 c_0$.