Linear congruence with Fermat's little theorem 987x ≡ 610 (mod 1597) 987x ≡ 610 (mod 1597)
Is this correct way of applying little Fermat's theorem for linear congruences? Does it make any sense? If not could someone advice a bit.
Since gcd(987,1597)=1
-> 987ˆ1597-1 ≡ 1 (mod 1597)
-> 987ˆ1596 ≡ 1 (mod 1597)
610 ≡ 610 (1597)

987ˆ1596 * 610 ≡ 610 (mod 1597)

987 * 987ˆ1595 * 610 ≡ 610 (mod 1597)

-> x0 = 987ˆ1595 * 610

->[987ˆ1595 * 610]127


For an explicit solution, you have to perform the extended Euclidean algorithm:
$$\begin{array}{rrrc}
& u_i&v_i&q_i \\
\hline
1597& 0&1 \\
987&1&0&1 \\
\hline
610&-1&1&1 \\
377&2&-1&1\\
233&-3&2&1\\
144&5&-3&1\\
89&-8&5&1\\
55&13&-8&1\\
34&-21&13&1\\
21&34&-21&1\\
13&-55&34&1\\
8&89&-55&1\\
5&-144&89&1\\
3&233&-144&1\\
2&-377&233&1 \\
1&\color{red}{610}&-377\\
\hline
\end{array}$$
Hence, a Bézout's relation between $987$ and $1597$ is $\;610\cdot 987-377\cdot 1597=1$, which shows that
$$987^{-1}\bmod 1597=610, \quad \text{whence }\; x\equiv 610^2\equiv \color{red}{-1\bmod1597}.$$
