The equotion should be restricted by (a,n) = 1.
And try the lemma below : given (a,n) = 1,r(1),r(2),...r(euler(n)) positive integers,and are less than m,and they and m relative primes,then the least (mod m) of the sequence a*r(1),a*r(2),...a*r(euler(n)) is a permutation of r(1),r(2)...r(euler(n))