Given the GCD and LCM of n positive integers, how many solutions are there

combinatoricsgcd-and-lcmnumber theoryreference-request

Question: Suppose you know $G:=\gcd$ (greatest common divisor) and $L:=\text{lcm}$ (least common multiple) of $n$ positive integers; how many solution sets exist?

In the case of $n = 2$, one finds that for the $k$ distinct primes dividing $L/G$, there are a total of $2^{k-1}$ unique solutions.

I am happy to write out a proof of the $n = 2$ case if desirable, but my question here concerns the more general version. The $n=3$ case already proved thorny in my explorations, so I would be happy to see smaller cases worked out even if responders are unsure about the full generalization.

Alternatively: If there is already an existing reference to this problem and its solution, then a pointer to such information would be most welcome, too!

Best Answer

If you are interested in counting tuples $(a_1,a_2,\dots,a_n)$ such that $\gcd(a_1,\dots,a_n) = G$ and $\operatorname{lcm}(a_1,\dots,a_n) = L$ then we can do it as follows.

If $L/G = \prod\limits_{i=1}^s p_i^{x_i}$ then each $a_i$ must be of the form $G \prod\limits_{j=1}^s p_i^{y_{i,j}}$ with $0 \leq y_{i,j} \leq x_i$.

Hence for each prime $p_i$ we require that the function from $\{1,\dots, n\}$ to $\mathbb N$ that sends $j$ to $y_{i,j}$ be a function that hits $0$ and $x_i$.

The number of such functions is easy by inclusion-exclusion for $x_i \geq 1$, it is $(x_i+1)^n - 2(x_i)^n + (x_i-1)^n$.

It follows the total number of tuples is $\prod\limits_{i=1}^s ( (x_i+1)^n - 2x_i^n + (x_i-1)^n)$.

Related Question