Generate *all* coprime tuples
05AB1E, 13 bytes

I think it has been 389 days since I last posted something here haha. There is definitely some golfing potential left in this program.

Code

Uses the 05AB1E-encoding.

∞æ¹ùʒPy.¿Q}²£


Try it online!



Explanation

It is worth noting that for two numbers \$n, m \in \mathbb{Z}^+\$ that:

$$
\tag{1} \label{1}
\gcd(n, m) \cdot \text{lcm}(n, m) = n \cdot m
$$

This means that for two numbers \$n, m \in \mathbb{Z}^+\$ where the \$\gcd(n, m) = 1\$, we can conclude that the \$\text{lcm}(n, m) = n \cdot m\$.

Furthermore, the \$\gcd\$ function is a multiplicative function, which means that if \$n_1\$ and \$n_2\$ are relatively prime, then:

$$
\gcd(n_1 \cdot n_2, m) = \gcd(n_1, m) \cdot \gcd(n_2, m)
$$



From this, we obtain the fact that:

$$
\tag{2} \label{2}
\gcd(a, bc) = 1 \iff \gcd(a, b) = 1 \wedge \gcd(a, c) = 1
$$



Let us denote a \$k\$-tuple of positive integers as \$S = \{x_1, x_2, \dots, x_k\}\$. A set \$S\$ is pairwise coprime, if and only if:  

$$
\tag{3} \label{3}
\forall a, b \in S \wedge a \not = b \rightarrow \gcd(a, b) = 1
$$



Using Equations \$\eqref{1}, \eqref{2}\$ and \$\eqref{3}\$, we can conclude that a set \$S = \{x_1, x_2, \dots, x_k\}\$ is pairwise coprime, if and only if:

$$
\text{lcm}(x_1, x_2, \dots, x_k) = \prod_{x \in S} x
$$

Code Explanation


∞æ¹ùʒPy.¿Q}²£

∞æ              # Powerset of the infinite list [1, ..., ∞].
  ¹ù            # Keep only lists of length k.
    ʒ     }     # Filter. Keep lists where the
     P          #   product of the list
         Q      #   is equal to
      y.¿       #   the least common multiple of the list
           ²£   # Retrieve the first n elements.