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

Given that $p+3=3k+2$ it follows that
$$2^{p+3}=2^{3k+2}=(2^3)^k\cdot2^2=8^k\cdot4\equiv1^k\cdot4=4\pmod7.$$
Plugging this into your next expression yields
$$5\cdot2^{p+3}-31\equiv5\cdot4-31\equiv-11\equiv3\pmod7.$$
