Problem 2197 · Hard

Replace Non-Coprime Numbers in Array

Repeatedly merge adjacent values that share a common factor into their least common multiple until no such pair remains. The visual highlights each adjacent pair and merges it on the stack.

Open the interactive visualisation