TITLE: Smallest positive integer that is not coprime to any member of a set of integers
QUESTION [13 upvotes]: Equivalently: given a list of numerators, find the lowest common denominator such that all the fractions formed can be simplified by cancellation.
Or: given a list of whole numbers, what's the smallest whole number that shares a common factor, greater than 1, with each of them? (Not necessarily the same factor shared with each member of the list.)
Clearly the given list cannot contain $\pm 1$ or no such number can be found! But for example, given $$\{8, 12, 45, 49\} = \{2^3, 2^2 \times 3, 3^2 \times 5, 7^2 \}$$ it is clear our desired number must include $2$ and $7$ in its prime factorisation, or else it will be coprime with $8$ and $49$. The fact $2$ is a factor guarantees a common factor with $12$ too, so we only need to ensure there is a common factor with $45 = 3^2 \times 5$ and this can be done most cheaply by incorporating a factor of $3$ in our prime factorisation. So the smallest number that does what we want is $2 \times 3 \times 7 = 42$, and indeed we find the greatest common divisors (highest common factors) are $\gcd(42, 8) = 2$, $\gcd(42, 12) = 6$, $\gcd(42, 45) = 3$ and $\gcd(42, 49) = 7$, so all greater than one. Alternatively, we observe that we can cancel down each of the fractions $\frac{8}{42} = \frac{4}{21}$, $\frac{12}{42} = \frac{2}{7}$, $\frac{45}{42} = \frac{15}{14}$ and $\frac{49}{42} = \frac{7}{6}$.
Does this procedure or function have a name? As a "lowest common non-coprime number" (though I can find no search engine hits under this name or close variants) it seems very closely related to the "lowest common multiple". Indeed, an obvious way to find a number that shares a factor with each member of the list is to just take
$$\operatorname{lcm}(8, 12, 45, 49) = 17640 = 2^3 \times 3^2 \times 5 \times 7^2$$
but this is clearly unnecessarily big. For starters, there's no need to raise the primes to a power — to ensure a common factor, each prime need only appear once. Dropping the unnecessary powers (i.e. taking the radical or square-free kernel — the largest divisor that is not, itself, divisible by a square number other than one) we get $2 \times 3 \times 5 \times 7 = 210$ but this is still not the smallest possible, since the prime factor $5$ wasn't required.
So what I want isn't the LCM, or even the radical of the LCM (or equivalently, the LCM of the radicals). In fact it's clear a good first step to simplify the problem would have been taking the radicals of all the numbers in our list, since the numbers sharing a factor with each of $\{2, 6, 15, 7\}$ are precisely the numbers sharing a factor with each of $\{8, 12, 45, 49\}$. Even then, it doesn't look like there's going to be a really neat algorithm to solve the problem. Consider:
$$\{2 \times 5, 3 \times 5, 2 \times 5\ \times 19 \} \text{ versus } \{2 \times 7, 3 \times 7, 2 \times 7 \times 19 \}$$
In the former case we can just use $5$ and a little thought shows it cannot be beaten; in the latter case, $7$ works but $2 \times 3 = 6$ is smaller. It seems we cannot avoid experimenting with different subsets of the prime factors to find the optimal answer. Nevertheless, the notion of a "lowest common non-coprime" function does seem interesting enough to crop up in some Math SE questions and I would like to know if mathematicians have given it a name, and whether there is an efficient algorithm (particularly if the list has already been given in prime-factorised form) for calculating it.

REPLY [4 votes]: I think this should be NP-hard, even if the prime factorisation is given.
The idea here is that given an instance of the (NP-hard) set cover problem with $n$ sets $S_1,\ldots,S_n\subset U$, you can reduce it to this problem by choosing $n$ primes $p_1,\ldots,p_n$ between $2^n$ and $2^{n+1}$, and allocating one prime to each set. Now encode each element $x\in U$ by $f(x)=\prod_{i:x\in S_i}p_i$.
A minimal set cover corresponds to a minimal-cardinality set of primes whose product has a common factor with $f(x)$ for each $x$. Also, the bounds on the primes mean that the set with minimal product (which is what you need for your problem) must also be a minimal-cardinality set.
The difficulty here is finding a suitable set of primes in polynomial time. There is certainly an algorithm to do this in polynomial expected time - pick numbers in range at random and use a polynomial-time primality test. The prime number theorem implies there are enough primes in range that you find $n$ of them after an expected polynomial number (in $n$) of tries. Whether there is a deterministic algorithm to find such a set (even assuming, say, generalised Riemann hypothesis) I don't know.