1

It is well-known that a linear congruence $ax\equiv b\pmod{n}$ has solutions if and only if the gcd $d:=(a,n)$ divides $b$, and then it has exactly $d$ incongruent ones, namely, $x=x_0+t\frac{n}{d}$ for $t=0,\dots,d-1$. My question is how many of these $x$ are units of $\mathbb{Z}_n$, i.e., $(x,n)=1$?

More generally, one can ask how many (incongruent) units occur in the arithmetic sequence $x_0+td'$ with $d'\mid n$. When $d'=1$, the answer is all of them, i.e., the Euler's totient $\varphi(n)$. It cannot be $\varphi(\frac{n}{d'})$ in general because if $x_0$ has non-trivial common divisors with $d'$ the answer will be $0$, but maybe it is true when $(x_0,d')=1$? Has this question been studied? It comes up when counting elements in certain centralizers and conjugacy classes.

Conifold
  • 12,093

2 Answers2

1

As here, let $\,{\rm gdc}(m,n) :=$ greatest divisor of $\,m\,$ that is coprime to $\,n\,$ (which can be efficiently computed by iteratively taking gcds). $ $ OP "generally" is the special case $\,a\mid c_a\,$ below.

Lemma $\ \color{#0a0}{(a,b,c)}\!=\!1\,\Rightarrow\, \bmod c\!:\ a\:\!\Bbb Z+b\,$ has $\,\phi(\bar a){\large \frac{c_a}{(c_a,a)}}\:\!$ units, for $\,\color{#c00}{\bar a = {\rm gdc}(c,a)},\ c_a = {\large \frac{c_{\vphantom{i}}}{\bar a^{\vphantom{i}}}}$

Proof $\ $ Let $\,f(x)=ax\!+\!b.\,$ $\,(f,c) = (f,\bar ac_a)=1\!\iff\!$ $(f,\bar a)=1,\,$ by $\,(f,c_a)\!=\!1,\,$ by prime $\,\color{#c00}{p\mid c_a\Rightarrow p\mid a},\,$ and $\,\color{#0a0}{(a,b,c)}\!=\!1.\,$ $\,\color{#c00}{(a,\bar a)\!=\!1}\Rightarrow f(x)\,$ is a $\rm\color{#0af}{bijection}$ $\!\bmod \bar a\,$ so it takes $\,\phi(\bar a)\,$ unit values, each of which lifts to $\,c_a/(c_a,a)\,$ units $\!\bmod c,\,$ by $\bmod c \!=\! \bar ac_a\!:\ f(x')\equiv f(x)\Rightarrow$ $\bmod \bar a\!:\ f(x')\equiv f(x)\,\ \rm\color{#0af}{thus}\ $ $x'\equiv x,\,$ so $\,x'-x = k\bar a,\,$ so $\,c\!=\!\bar ac_a\mid f(x')-f(x) = ak\bar a\!\iff\! c_a/(c_a,a)\mid k$.

Conifold
  • 12,093
Bill Dubuque
  • 282,220
0

This is an unpacking by the OP of Bill Dubuque's proof that some users may find easier to follow.

Lemma. Suppose $(a,b,c)\!=\!1$ and let $\bar{a}$ denote the largest divisor of $c$ relatively prime to $a$. Then the number of incongruent units modulo $c$ in the sequence $ax+b$ is $$ \frac{c}{(a\bar{a},c)}\,\phi(\bar{a})\,. $$

Proof$\ $ Since $(a,\bar{a})=1$ the map $x\mapsto ax+b$ is bijective modulo $\bar{a}$, so the number of units modulo $\bar{a}$ is just $\phi(\bar{a})$. We will first show that $(ax+b,\bar{a})=(ax+b,c)$, so that any unit modulo $\bar{a}$ is also a unit modulo $n$.

Note that $(ax+b,\frac{c}{\bar{a}})=1$. Indeed, if a prime $p\mid\frac{c}{\bar{a}}$ then $p\mid a$ because the only factors left in $\frac{c}{\bar{a}}$ are those shared with $a$. Moreover, $p\mid c$ and if also $p\mid ax+b$ then $p\mid (ax+b)-ax=b$. But then $p\mid(a,b,c)$ contrary to the assumption. Since multiplication by a relatively prime factor does not change the gcd, $$ (ax+b,c)=\big(ax+b,\frac{c}{\bar{a}}\,\bar{a}\big)=(ax+b,\bar{a}) $$

It remains to count incongruent $ax'+b$ modulo $c$ that are congruent to a given unit $ax+b$ modulo $\bar{a}$. By the above, they will automatically be units modulo $c$ and, jointly, will exhaust all of them because any unit modulo $c$ projects to a unit modulo its divisor $\bar{a}$.

To this end, if $ax'+b\equiv ax+b\pmod{\bar{a}}$ then $x'\equiv x\pmod{\bar{a}}$ since $a$ is invertible modulo $\bar{a}$, so $x'-x=\bar{a}k$. Therefore, $$ (ax'+b)-(ax+b)=a(x'-x)=a\bar{a}\,k. $$ Since the above reasoning is reversible, we conclude that $ax'+b$ congruent to $ax+b$ modulo $\bar{a}$ are precisely those separated from $ax+b$ by multiples of $a\bar{a}$. But the arithmetic sequence $(ax+b)+a\bar{a}\,k$ is periodic modulo $c$ with the minimal period $\frac{c}{(a\bar{a},c)}$ and so contains $\frac{c}{(a\bar{a},c)}$ such terms.

Thus, we have $\phi(\bar{a})$ units modulo $\bar{a}$ with $\frac{c}{(a\bar{a},c)}$ lifts modulo $c$ attached to each, giving us the stated total. $\ \ \ \square$

Conifold
  • 12,093