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

$2^3=8$, so the remainder when you divide $2^3$ by 7 is 1.  That means $2^3=1\pmod7$.
$2^{3k}=(2^3)^k$ because of power laws.  This equals $(7+1)^k$.  Expand this using the Binomial Theorem, and all the terms are multiples of 7 except for the final term which is 1.  So $2^{3k}=1\pmod7$.
Lastly, $2^{3k+2}=2^{3k}2^2=4.2^{3k}$.  But $2^{3k}=7m+1$ for some number $m$, so $4.2^{3k}=4(7m+1)=7(4m)+4=4\pmod7$
