values of distinct positive integers. Link two numbers whenever they have a common divisor greater than 1. Links chain together: if a is linked to b and b to c, all three are in the same group, even when a and c share no divisor.
Return how many numbers the largest group contains.values=[10, 21, 14, 9, 11] → 4
10 and 14 share 2, 14 and 21 share 7, 21 and 9 share 3, so 10, 14, 21 and 9 form one group; 11 shares no factor with anyone. The answer is 4.
values=[8, 25, 27, 49] → 1
Every two of these numbers are coprime, so each group holds a single number.
values=[6, 35, 1, 15] → 3
values are distinctvalues=[10, 21, 14, 9, 11]
4
Run checks the first 3 tests in your browser. Submit checks all 99 tests on the server, hidden ones included.