<s>[INST] Solving a system of linear congruences 
Find all positive integer solutions to \begin{align*}x &\equiv -1 \pmod{n} \\ x&\equiv 1 \pmod{n-1}. \end{align*}

I rewrote the system as $x = nk_1-1$ and $x = (n-1)k_2+1$. Thus, we have $nk_1-1 = (n-1)k_2+1$ and so $n(k_1-k_2) = 2-k_2 \implies n = \frac{2-k_2}{k_1-k_2}$. How do I solve it from here?
 [/INST] The two congruences are equivalent to $$\begin{cases}x=nu-1\\x=(n-1)v+1\end{cases}$$
It follows the diophantine equation $$nu-(n-1)v=2$$ which admits the particular solution $(u,v)=(2,2)$ hence the general solution is  $$\begin{cases}u=(n-1)t+2\\v=nt+2\end{cases}$$ Finally one has
$$x=n((n-1)t+2)-1$$ where $t$ is an arbitrary integer.
(The first congruence is clearly verified; the second gives $x\equiv 2n-1\equiv 1\pmod{n-1}$ because of $2n-1=2(n-1)+1$)
</s>