If $d \mid n-1$ and $d \mid n^2+2$, show that $d\mid3$
$n-1=\alpha d \tag 1$
$n^2+2=\beta d \tag 2$
for some $\alpha,\beta$.
Now we must show $3=\gamma d$ for some $\gamma$.
Adding (1) and (2), we get $$n^2+n+1=(\alpha+\beta)d = \gamma d$$
I'm having some trouble from here onwards. Have I done the steps correctly thus far? Thanks!