Proving divisibility of sum of seven consecutive integers by 7 using congruence theories I have have this peculiar problem below;
For which values of n, a consecutive set of seven integers, raised to it's nth power and added together, will be divisible by 7?
For example if a is any integer then the sum of seven consecutive integers when n=1 is;
a + (a+1) + (a+2) + (a+3) +  (a+4) + (a+5) + (a+6) = 7a+21
which is divisible by 7.
I can prove it's divisible using polynomials for n=2,3 or 4 but that doesn't involve the use of congruence theories. I tried to apply Fermat Little Theorem, but it didn't get me anywhere
$a,a+1,a+2,a+3,a+4,a+5$, and $a+6$ comprise a complete set of residues modulo $7$,
so we can take $a=0$ without loss of generality.
For $n=1$, the sum is congruent to $0+1+2+3+4+5+6\equiv0\bmod7$.
For $n=2$, the sum is congruent to $0+1+4+2+2+4+1\equiv0\bmod7$.
For $n=3$, the sum is congruent to $0+1+1-1+1-1-1\equiv0\bmod7$.
For $n=4$, the sum is congruent to $0+1+2+4+4+2+1\equiv0\bmod7$.
For $n=5$, the sum is congruent to $0+1+4+5+2+3+6\equiv0\bmod7$.
For $n=6$, the sum is congruent to $0+1+1+1+1+1+1\equiv6\bmod7$.
For $n=6k+m$, the sum is congruent to that for $m$, as a consequence of Fermat's little theorem.
Therefore, the sum is a multiple of $7$ unless $n$ is a multiple of $6$.
First of all if $a_1, a_2,....,a_7$ are consecutive then then are congruent to a complete residue class.  That is for $r_1, .....r_2 = 0,....,6$ then exactly one $a_i$ is congrent to each $r_i$.
By Fermat's little thereom if $n = 6k + j$ then $a_i^n\equiv (a_i^{6})^ka_i^j \equiv \begin{cases}0\equiv a_i^j\pmod 7 &amp;a_i\equiv 0 \pmod 7\\1^ka_i^j\equiv a_i^j\pmod 7&amp;a_i\not \equiv 0\pmod 7\end{cases}\equiv a_i^j$
So we need do test these for $n\equiv j; j=0,1,2,3,4,5$.
Now $6\equiv -1$ and $5\equiv -2$ and $4 \equiv -3\pmod 7$ so
$a_1^n + a_2^n + ... + a_7^n \equiv ((-3)^j + (3)^j) + ((-2)^j + 2^j) + (-1^j + 1^j) + 0^j\pmod 7$.
If $j$ is odd we are done $(-m)^j + m^j\equiv 0 \pmod 7$ and the sum is equivalent to $0\pmod 7$.
If $j$ is even we'll have to try them.
If $j = 0$ we have $a_1^n + a_2^n + ... + a_7^n \equiv 1+1+1+1+1+1+0\equiv 6\pmod 7$.  No good.
If $j=2$ we have $a_1^n + a_2^n + ... + a_7^n\equiv 9+9+4+4+1+1+0\equiv 2*14\equiv 0$.  So that is good.
If $j=4$ we have $a_1^n + a_2^n + ... + a_7^n\equiv 2*3^4 + 2*2^4+2*1^4+0\equiv 2*9^2 +2*16 + 2\equiv 2*2^2 + 2*2 + 2= 8+ 6=1-1\equiv 0\pmod 7$.  So that is good.
So the only time this does not work is if $n$ is a multiple of $6$.
=====
I could probably have done this a little slicker to note that $3$ is a primitive root mod $7$. ($3^{k=1,2,....,6}\equiv 3,2,6,4,5,1\pmod 7$) and so $\sum a_i^n\equiv \sum_{i\ne 0} 3^{in}$ but then noteting that $3^k\equiv - 3^{k+3\pmod 6}$ the terms cancel out so long as $n\not \equiv 0\pmod 6$.  (And for $n\equiv 0 \pmod 6$ it is evident that $\sum a_i^n\equiv \sum_{a_i\not \equiv 0\pmod 7} 1\equiv -1\pmod 7$.)