Use Euler's theorem, which states that for any integer $\displaystyle a$, relatively prime to $\displaystyle n$,
$\displaystyle a^{\phi(n)} \equiv 1 \mod n$
where $\displaystyle \phi$ is Euler's phi function.
So, by Euler's theorem, with $\displaystyle \phi(391)=(17-1)(23-1)=352$, you have $\displaystyle 2^{352} \equiv 1 \mod 391$.
For the first part you can use the Chinese Remainder Theorem. You have :
$\displaystyle 2^{391} \equiv (2^{17})^{23} \equiv 2^{23} \equiv 2^{17}2^6 \equiv 2^7 \equiv 128 \equiv 9 \mod 17$
so it's impossible that $\displaystyle 2^{391} \equiv 2 \mod 391$.
Matlab is for engineers.