Subfield: Algebra


Question: Let $a, b, c, d$ be positive integers such that $a d \neq b c$ and $\operatorname{gcd}(a, b, c, d)=1$. Prove that, as $n$ runs through the positive integers, the values $\operatorname{gcd}(a n+b, c n+d)$ may achieve form the set of all positive divisors of some integer.

Solution:
We extend the problem statement by allowing $a$ and $c$ take non-negative integer values, and allowing $b$ and $d$ to take arbitrary integer values. (As usual, the greatest common divisor of two integers is non-negative.) Without loss of generality, we assume $0 \leq a \leq c$. Let $S(a, b, c, d)=\left\{\operatorname{gcd}(a n+b, c n+d): n \in \mathbb{Z}_{>0}\right\}$.

Now we induct on $a$. We first deal with the inductive step, leaving the base case $a=0$ to the end of the solution. So, assume that $a>0$; we intend to find a 4 -tuple $\left(a^{\prime}, b^{\prime}, c^{\prime}, d^{\prime}\right)$ satisfying the requirements of the extended problem, such that $S\left(a^{\prime}, b^{\prime}, c^{\prime}, d^{\prime}\right)=S(a, b, c, d)$ and $0 \leq a^{\prime}<a$, which will allow us to apply the induction hypothesis.

The construction of this 4-tuple is provided by the step of the Euclidean algorithm. Write $c=a q+r$, where $q$ and $r$ are both integers and $0 \leq r<a$. Then for every $n$ we have

$$
\operatorname{gcd}(a n+b, c n+d)=\operatorname{gcd}(a n+b, q(a n+b)+r n+d-q b)=\operatorname{gcd}(a n+b, r n+(d-q b)) \text {, }
$$

so a natural intention is to define $a^{\prime}=r, b^{\prime}=d-q b, c^{\prime}=a$, and $d^{\prime}=b$ (which are already shown to satisfy $\left.S\left(a^{\prime}, b^{\prime}, c^{\prime}, d^{\prime}\right)=S(a, b, c, d)\right)$. The check of the problem requirements is straightforward: indeed,

$$
a^{\prime} d^{\prime}-b^{\prime} c^{\prime}=(c-q a) b-(d-q b) a=-(a d-b c) \neq 0
$$

and

$$
\operatorname{gcd}\left(a^{\prime}, b^{\prime}, c^{\prime}, d^{\prime}\right)=\operatorname{gcd}(c-q a, b-q d, a, b)=\operatorname{gcd}(c, d, a, b)=1 .
$$

Thus the step is verified.

It remains to deal with the base case $a=0$, i.e., to examine the set $S(0, b, c, d)$ with $b c \neq 0$ and $\operatorname{gcd}(b, c, d)=1$. Let $b^{\prime}$ be the integer obtained from $b$ by ignoring all primes $b$ and $c$ share (none of them divides $c n+d$ for any integer $n$, otherwise $\operatorname{gcd}(b, c, d)>1)$. We thus $\operatorname{get} \operatorname{gcd}\left(b^{\prime}, c\right)=1$ and $S\left(0, b^{\prime}, c, d\right)=S(0, b, c, d)$.

Finally, it is easily seen that $S\left(0, b^{\prime}, c, d\right)$ is the set of all positive divisors of $b^{\prime}$. Each member of $S\left(0, b^{\prime}, c, d\right)$ is clearly a divisor of $b^{\prime}$. Conversely, if $\delta$ is a positive divisor of $b^{\prime}$, then $c n+d \equiv \delta$ $\left(\bmod b^{\prime}\right)$ for some $n$, since $b^{\prime}$ and $c$ are coprime, so $\delta$ is indeed a member of $S\left(0, b^{\prime}, c, d\right)$.
For positive integers $s$ and $t$ and prime $p$, we will denote by $\operatorname{gcd}_{p}(s, t)$ the greatest common $p$-power divisor of $s$ and $t$.

Claim 1. For any positive integer $n, \operatorname{gcd}(a n+b, c n+d) \mid a d-b c$.

Proof. This is clear from the identity

$$
a(c n+d)-c(a n+b)=a d-b c . \tag{\dagger}
$$

Claim 2. The set of values taken by $\operatorname{gcd}(a n+b, c n+d)$ is exactly the set of values taken by the product

$$
\prod_{p \mid a d-b c} \operatorname{gcd}_{p}\left(a n_{p}+b, c n_{p}+d\right)
$$

as the $\left(n_{p}\right)_{p \mid a d-b c}$ each range over positive integers.



Proof. From the identity

$$
\operatorname{gcd}(a n+b, c n+d)=\prod_{p \mid a d-b c} \operatorname{gcd}_{p}(a n+b, c n+d),
$$

it is clear that every value taken by $\operatorname{gcd}(a n+b, c n+d)$ is also a value taken by the product (with all $\left.n_{p}=n\right)$. Conversely, it suffices to show that, given any positive integers $\left(n_{p}\right)_{p \mid a d-b c}$, there is a positive integer $n$ such that $\operatorname{gcd}_{p}(a n+b, c n+d)=\operatorname{gcd}_{p}\left(a n_{p}+b, c n_{p}+d\right)$ for each $p \mid a d-b c$. This can be achieved by requiring that $n$ be congruent to $n_{p}$ modulo a sufficiently large ${ }^{1}$ power of $p$ (using the Chinese Remainder Theorem).

Using Claim 2, it suffices to determine the sets of values taken by $\operatorname{gcd}_{p}(a n+b, c n+d)$ as $n$ ranges over all positive integers. There are two cases.

Claim 3. If $p \mid a, c$, then $\operatorname{gcd}_{p}(a n+b, c n+d)=1$ for all $n$.

Proof. If $p \mid a n+b, c n+d$, then we would have $p \mid a, b, c, d$, which is not the case.

Claim 4. If $p \nmid a$ or $p \nmid c$, then the values taken by $\operatorname{gcd}_{p}(a n+b, c n+d)$ are exactly the $p$-power divisors of $a d-b c$.

Proof. Assume without loss of generality that $p \nmid a$. Then from identity $(\dagger)$ we have $\operatorname{gcd}_{p}(a n+$ $b, c n+d)=\operatorname{gcd}_{p}(a n+b, a d-b c)$. But since $p \nmid a$, the arithmetic progression $a n+b$ takes all possible values modulo the highest $p$-power divisor of $a d-b c$, and in particular the values taken by $\operatorname{gcd}_{p}(a n+b, a d-b c)$ are exactly the $p$-power divisors of $a d-b c$.

Conclusion. Using claims 2,3 and 4 , we see that the set of values taken by $\operatorname{gcd}(a n+b, c n+d)$ is equal to the set of products of $p$-power divisors of $a d-b c$, where we only consider those primes $p$ not dividing $\operatorname{gcd}(a, c)$. Thus the set of values of $\operatorname{gcd}(a n+b, c n+d)$ is equal to the set of divisors of the largest factor of $a d-b c$ coprime to $\operatorname{gcd}(a, c)$.