Find minimum GCD of all pairs in an array | Python3 program to find the minimum GCD of any pair in the array ; Function returns the Minimum GCD of any pair ; Finding GCD of all the elements in the array . ; Driver code
from math import gcd NEW_LINE def MinimumGCD ( arr , n ) : NEW_LINE INDENT g = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT g = gcd ( g , arr [ i ] ) NEW_LINE DEDENT return g NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 2 , 4 , 6 , 8 , 3 ] NEW_LINE N = len ( arr ) NEW_LINE print ( MinimumGCD ( arr , N ) ) NEW_LINE DEDENT