Always divisible by $5$ Find the number of ordered 8-tuples $(a_7,a_6,\ldots,a_0) $ of nonnegative integers such that $0 \le a_i \le 4$ for all $i$, and
$$a_7n^7+a_6n^6+a_5n^5+a_4n^4+a_3n^3+a_2n^2+a_1n+a_0 \equiv 0 \pmod{5}$$
for all integers $n$. I tried placing $n=0,+1,-1$ but  don't think it solves the problem. 
 A: Hint #1

If the polynomial $$f = a_{7} x^{7} + a_{6} x^{6} + \dots + a_{1} x +  a_{0} \in \mathbb{Z}/5 \mathbb{Z}[x]$$ vanishes on $\mathbb{Z}/5 \mathbb{Z}$, it must be a multiple of $x^{5} - x \in \mathbb{Z}/5 \mathbb{Z}[x]$.

Hint #2

So $f = (x^{5} - x) \cdot g$, where $g$ is an arbitrary polynomial of degree $7 - 5 = 2$. How many $g$ there are?

Hint #3

So we get $$ f = (x^{5} - x) (b_{2} x^{2} + b_{1} x + b_{0}) = b_{2} x^{7} + b_{1} x^{6} + b_{0} x^{5} - b_{2} x^{3} - b_{1} x^{2} - b_{0} x.$$ So we have $5^{3}$ such polynomials, and exactly as in the answer of Geoff Robinson, they are characterized by $a_{0} = a_{4} = 0$, $a_{7} = - a_{3}$, $a_{6} = - a_{2}$, and $a_{5} = - a_{1}$.

A: You clearly need $a_{0} = 0.$ Then, since $n^{4} \equiv 1$ (mod $5$), you need $a_{7}n^{2}+ a_{6}n+ a_{5} +a_{4}n^{3} + a_{3}n^{2} + a_{2}n +a_{1} \equiv 0$ (mod $5$) whenever $n$ is not a multiple of $5$. Hence the polynomial $a_{4}x^{3} + (a_{3}+a_{7})x^{2} + (a_{6}+a_{2})x +(a_{5}+a_{1}) \in \mathbb{Z}_{5}[x]$ has $4$ roots in $\mathbb{Z}_{5}.$ (Here, $\mathbb{Z}_{5}$ denotes $\mathbb{Z}/5\mathbb{Z}).$ From which you can conclude....
A: Expanding the comment by MooS, first observe that the condition is just saying that reduction modulo $5$ of the polynomial gives a polynomial in $\Bbb F_5[x]$ that vanishes (in $\Bbb F_5$) under each of the substitutions of $0,1,2,3,4$ for $x$. The reduction (which is the reason for limiting the coefficients as they are) gives you an $8$-dimensional  vector space over $\Bbb F_5$, and each vanishing condition defines a hyperplane of this space; you need to find the dimension of their intersection.
This intersection turns out to be of minimal possible dimension $8-5=3$, as each successive intersection decreases the dimension by$~1$. To see that this is the case, consider the contrary case: it would have to be that at some point the previous intersection is already contained in the hyperplane intersected with next. But that would mean that all polynomials that vanish in $0,\ldots,k-1$ automatically vanish in$~k$, for some $k\in\Bbb F_5$. But the polynomial $x(x-1)\ldots(x-k-1)$ shows that this is false. So each intersection removes some polynomials, and decrease the dimension by$~1$. The answer then is $5^3=125$.
