human
Smallest number dividing minimum number of elements in the array | Set 2 | Function to return the smallest number that divides minimum number of elements in the given array.
m stores the maximum in the array.
Frequency array.
Sieve.
Incrementing j.
If no multiples of j are in the array.
Driver code"
Solution in Python:
assistant
#Here is code to smallest number dividing minimum number of elements in the array and the other steps required.
 def findMin ( arr , n ) :
	m = 0
	for i in range ( n ) :
		m = max ( m , arr [ i ] )
	freq = [ 0 ] * ( m + 2 )
	for i in range ( n ) :
		freq [ arr [ i ] ] += 1
	for i in range ( 1 , m + 2 ) :
		j = i
		cnt = 0
		while ( j <= m ) :
			cnt += freq [ j ]
			j += i
		if ( not cnt ) :
			return i
	return m + 1
arr = [ 2 , 12 , 6 ]
n = len ( arr )
print ( findMin ( arr , n ) )