Finding $n$ such that $a^{17n} - a^2$ is divisible by $311$ for any integer $a$ Find a positive integer $n$ such that for any integer $a^{17n} - a^2$ is divisible by $311$.

I have no idea really where to take this question. It is a part c of an exam. Part a looked for a primality test on $311$ and part b asked me to compute $13$ to the power of $932$ mod $311$. 
 A: Hint As $311$ is prime, there exists a primitive root modulo $311$.
Let $a$ be a primitive root modulo $311$.
Then $a$ is invertible modulo 311
$$a^{17n} \equiv a^2 \pmod {311} \Rightarrow a^{17n-2} \equiv 1 \pmod {311}$$
As $a$ is a primitive root, it means that $310$ must divide $17n-2$.
Find the some $n$ so this happens, and then show that it works for all $a$. 
A: As $311$ is prime, either $311|a$ or $(311,a)=1$
If $311|a, 311|(a^{17n}-a^2)$
Else  $(311,a)=1$ so, $311|(a^{17n}-a^2)\implies 311|(a^{17n-2}-1)\iff a^{17n-2}\equiv1\pmod {311}$
As $311$ is prime, the order of $a$  can be $311-1=310$ and its divisors, the highest order will be $310$ in case of primitive roots
$\implies 310$ must divide  $17n-2$ 
So, $17n-2=310m$ for some integer $m$
Using continued fraction  $$\frac{310}{17}=18+\frac4{17}=18+\frac1{\frac{17}4}=18+\frac1{4+\frac14}$$
The previous convergent of $\frac{310}{17}$ is $18+\frac14=\frac{73}4$
Using the Theorem $#3$ of this, $17\cdot73-310\cdot4=1$
$\implies17n-310m=2(17\cdot73-310\cdot4)$
$\implies 17(n-146)=310(m-8)$
$\implies \frac{17(n-146)}{310}=m-8$ which is an integer
$\implies310|17(n-146)$
$\implies310|(n-146)$ as $(17,310)=1$
$\implies n-146=310r$ for some integer $r$
