How does one get from $p+3=3k+2$ then $2^{p+3} \equiv 4 \pmod 7$, to $5 \cdot 2^{p+3} -31 \equiv 3 \pmod7$ How does one get from $p+3=3k+2$ then $2^{p+3}\equiv4 \pmod 7$, to $5 \cdot 2^{p+3} -31 \equiv 3 \pmod7$.
I am just starting with modular arithmetic so any help would be greatly appreaciated.
Credit to user236182 for original answer, just wanted to know how he got to it

First look at the powers of $2$ modulo $7$. In particular note that $2^3\equiv1\pmod7$. Hence $2^{3k+a}\equiv 2^{3k}2^a\equiv2^a\pmod7$.
This gives us the first part of the question:
$$p+3=3k+2\hspace{5mm}\implies\hspace{5mm} 2^{p+3}\equiv2^{3k+2}\equiv2^2\equiv4\pmod7$$
The second part is pretty straightforward too:
$$5\cdot4-31\equiv-11\equiv3\pmod 7$$
hence
$$5\cdot2^{p+3}-31\equiv3\pmod7$$
