Number theory problem with many variables in a sequence Very cool number theory problem I was reading!
Problem: Let $a_1 < a_2 < a_3 < a_4$ be positive integers such that the following conditions hold:
• $gcd(a_i, a_j) > 1$ holds for all integers $1 \leq i < j \leq 4$;
• $gcd(a_i, a_j, a_k) = 1$ holds for all integers $1 \leq i < j < k \leq 4$.
Find the smallest possible value of $a_4$.
Solution:
I first realized that each of $a_1, a_2, a_3,$ and $a_4$ were $3$ prime numbers multiplied by each other. This is because if the gcd of $2$ of the numbers must be greater than $1$ and the gcd of $3$ of the numbers must be $1$, each number must be $3$ numbers multiplied by each other ($2$ numbers have $1$ factor similar with another and no $3$ numbers have the same factors) and that each was prime to maintain this condition.
I then started seeking for prime numbers to fit this condition. I realized one fact right here that saved me a lot of time. Since there were $4$ different numbers and they had to fit these conditions, there had to be a total of $6$ different prime numbers used across all $4$ numbers' prime factorizations. Since the problem asked for the smallest possible value of $a_4$, we have to use the first $6$ prime numbers across the prime factorizations of the $4$ numbers. I am then now stuck on which $3$ prime numbers of each have to go to which number.
I am thinking that I will have to guess and check where to put $2, 3, 5, 7, 11,$ and $13$ into the prime factorizations of the $4$ numbers. Each number must have $3$ different prime numbers used in its prime factorization and each pair of $2$ numbers must have exactly one prime factor in common.
Please help me if there is a different way to solve this problem or if guessing and checking is the only way. I feel like guessing an checking is the best way. Also, I need help on what numbers to guess and check next to find $a_4$. Thanks in advance!
 A: I agree with your analysis, and it turns out to be easy to find the best arrangement by guessing, and then showing that the guess is correct.
First assume that we will never have $11$ and $13$ in the same group, so $2$ of the groups contain $11$, and the other two contain $13$.
Assume also that we will do best to keep $5$ and $7$ separate.  Now our $4$ groups contain $$5,11\\7,11\\5,13\\7,13$$
The largest product is $7\cdot13$, so we make our last assumption: the third number in the final group should be $2$.  Now the second $2$ can't go with $7$ or $13$, so it must go in the first group, and we have
$$2\cdot5\cdot11=110\\
3\cdot7\cdot11=231\\
3\cdot5\cdot13=195\\
2\cdot7\cdot13=182$$
with maximum $231$.
Now to validate our assumptions.  If $11$ and $13$ are in the same group, the product would be at least $2\cdot11\cdot13=186>231$, so the first assumption is valid.
If $5$ and $7$ were in the same group, the product would be at least $5\cdot7\cdot11>231,$ and the second assumption is valid.
Finally putting $3$ in the last group would give $3\cdot7\cdot13>231$ and the third assumption is valid.
