I was solving a question on finding cycles in linked-list. The solution is to place two runner nodes one that moves by 1 node each iteration and the other that moves 2 nodes per iteration. So if the pointers were to meet at anytime we would detect a cycle. Now I wanted to prove that this is a correct solution and a question that arose was the following:
Is there a solution for i (apart from zero) to the general equation $(i+x)\text{mod}(n)$ = $(ki+y)\text{mod}(n)$ if k, x and y are given?
In the above case: k=2, x=0, y=0
The congruence $$ i+x \equiv ki+y \pmod n $$ is equivalent to $$ (k-1)i \equiv x-y\pmod n. $$ When $k,x,y$ are given, this is a linear congruence in the variable $x$, and solving such a congruence is a well-known task that you can easily search for. You'll learn, for example, that you should define $g=\gcd(k-1,n)$; if $g$ divides $x-y$, then there are $g$ solutions modulo $n$, otherwise there are no solutions.