Find minimum GCD of a pair of elements in an array

320 Views Asked by At

Given an list of elements, I have to find the MINIMUM GCD possible between any two pairs of the array in least time complexity.

Example

Input

list=[7,3,14,9,6]

Output

1

Explanation

min gcd can be of pair(7,3)

My naive solution-

I am just considering pairs of elements one by one to find the min gcd.
Is there any formula or efficient way to find out min gcd?