\[(p-1)2^{p-1}+1\]
is divisible by \[p\]
. We can show this using Fermat's Little Theorem. Working modulo p,\[\begin{equation} \begin{aligned} (p-1)2^{p-1}+1 & \equiv (p-1) \times 1+1 \; (mod \; p) \\ & \equiv 0 \; (mod \; p) \end{aligned} \end{equation}\]
\[(p-2)2^{p-2}+1\]
is divisible by \[p\]
. We can show this again using Fermat's Little Theorem. Working modulo p,\[\begin{equation} \begin{aligned} (p-2)2^{p-2}+1 & \equiv (-2)2^{p-2}+1 \; (mod \; p) \\ &=-2^{p-1}+1 \\ & \equiv -1+1 \; (mod \; p) \\ & \equiv 0 \; (mod \; p) \\ & \equiv 0 \; (mod \; p)\end{aligned} \end{equation}\]