I'm trying to figure out this problem, with which I could use some help:
Problem: Under what conditions is the map $$ \pi : \left\{1, 2, \ldots, n-1\right\} \to \left\{1, 2, \ldots, n-1\right\}: i \mapsto (ai +b) \bmod n $$ a permutation ($a, b \in \mathbb{Z}$) ?
Attempt: For $\pi$ to be a permutation, it must be bijective. So first I was trying to figure out under what conditions it is injective. I let $i, j \in \left\{1, \ldots, n-1\right\}$, and I suppose that $i \neq j$. When is $\pi(i) \neq \pi(j)$? I think when $(ai) \bmod n \neq (aj) \bmod n$, or when $$ i \neq j + qn \qquad (q \in \mathbb{Z}) $$ that is, when $i$ is not some multiple of $j$ in terms of $n$.
For surjectivity, I let $j \in \left\{1, \ldots, n-1\right\}$. I need to find an $i \in \left\{1, \ldots, n-1\right\}$ such that $$ \pi(i) = (ai + b) \bmod n = j. $$ I'm not sure how to fulfill this condition.
Help is appreciated.