Let $z=7^{2018}-1$
Theorem. : Let $p \in \mathbb{N}$ be any prime and $a \in \mathbb{Z}$. If $p$ doesn't divide $a$, then $p$ divides $a^{p-1}-1$
$$ z=\left(7^{1009}\right)^2-1=\left(7^{1009}\right)^{3-1}-1 $$ For $p=3$ and $a=7^{1009}$ the theorem gives: $$ z \bmod 3=0 $$ Any hints on how to proceed to find $z \bmod 5$?
Note: Some kind of error occurred and the important part of the last sentence got deleted/never composed. I apologize for the ambiguity of my question in its previous form.
Do it the EXACT same way.
$5 -1 = X$
And $2018\div X = Q$ with $R$ remaider.
So $7^{2018}-1 = (7^{Q})^X*7^R - 1 \equiv 7^R - 1 \pmod 5$.
Figuring $7^R-1$ can be done by hand as $7\equiv 2\pmod 5$ so $7^R\equiv 2^R\pmod 7$ and $R < 5$.
.....
But I do have advice: Don't to $7^{2018} - 1 = (7^{2018})^2 - 1 \equiv 1-1 \equiv 0 \pmod 3$. Do $7^{2018} -1 = (7^2)^{2018} - 1 \equiv 1^{2018} - 1\equiv 0 \pmod 3$. It'll make things easier when $2018\div (p-1)$ has a remainder (as it does with $p = 5$)