I have the ring $\Bbb Z_q = \{0,1,\ldots,q-1\}$, where $q$ is a prime. Starting from $0$, I want to make exactly $n$ equally sized increments and reach $a\in \Bbb Z_q$, with $n<q-1$. For example if $q = 5$, and I want to reach $a=3$ with $n=4$ increments, I would use increments of $2$:
0 -> 2 -> 4 -> 1 -> 3
Is there a way to calculate the size of the increments that I need in O(1) time (i.e., without testing all possible answers)?