GCD of Everything — Solution & Editorial
Fold the Euclidean gcd across the array; it only shrinks, and gcd(0, x) = x starts the fold cleanly.
Complexity: O(N log max)
Fold the Euclidean gcd across the array; it only shrinks, and gcd(0, x) = x starts the fold cleanly.
Complexity: O(N log max)