$n\mid P(a)$ for all $a\in\Bbb Z\iff P(a)\equiv 0\pmod{\!n}$ for all $\,a\in\Bbb Z_n$

elementary-number-theorymodular arithmetic

In my textbook, it says,

The sum of the cubes of any three consecutive integers is divisible by
$9$

This statement is equivalent to proving,

$(n^3 + (n+1)^3 + (n+2)^3 ) \mod 9 =0$ is true for $n=0,1, \ldots, 8$

Now I understand how the modulo function works but I just don't see how the latter part is the same as the former. Can anyone walk me through it?

Note that, I'm not really looking for the proof, what I am looking for is how the first and the second statement are related.

Follow up question which begs to be asked,

Given some expression of $a \in \mathbb{Z}$, say $P(a)$, are the following 2 statements equivalent?

  1. $n$ divides $P(a), \, \forall a \in \mathbb{Z}$ and for some fixed $n \in \mathbb{N}$

  2. $P(a) \mod n = 0, \forall a \in \{0,1, \ldots, n-1\}$

Can anyone explain me whether or not the two statements are equivalent? Thanks!

Best Answer

$$ n | P(a) \ \forall \ a\in \mathbb Z \iff P(a) \mod n = 0 \ \forall \ a\in \{0,1,2\dots n-1\}$$ The key here is that if all elements $e$ in this set satisfy this property, then all numbers of the form $e+nk$ for some integer $k$ also satisfy this property, as the $kn$ term gets vanished mod $n$. For instance, $$ n^3 +(n+1)^3 +(n+2)^3 \equiv (n+9k)^3 +(n+9k+1)^3 +(n+9k+2)^3 \pmod 9 $$ because $$(n+9k)^3 = n^3 +9^3k^3 +3n^2(9k) +3(n)(9^2k^2) = n^3 +9(\text{stuff}) $$ and similarly for the other two terms.

Related Question