values, each at least 2. Cut it into contiguous chunks so that every element lands in exactly one chunk and all numbers inside a chunk share a divisor greater than 1 (that is, the GCD of the chunk is above 1).
Return the smallest possible number of chunks.values=[10, 15, 25, 9, 21, 4] → 3
The split [10, 15, 25] | [9, 21] | [4] works, with GCDs 5, 3 and 4. Two chunks are not enough: 25 and 9 share no divisor, and neither do 21 and 4.
values=[6, 12, 18] → 1
Every number is divisible by 6, so the whole array is one chunk.
values=[7, 11] → 2
values=[10, 15, 25, 9, 21, 4]
3
Run checks the first 3 tests in your browser. Submit checks all 157 tests on the server, hidden ones included.