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
 A: 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.$$
A: 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$$
A: $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$
