Smallest positive integer that does not divide any elements of the given array | Function to find the smallest number which doesn 't divides any integer in the given array arr[] ; Traverse the array arr [ ] ; Maximum array element ; Initialize variable ; Traverse from 2 to max ; Stores if any such integer is found or not ; If any array element is divisible by j ; Smallest integer ; Prthe answer ; Driver Code ; Function Call
def smallestNumber ( arr , lenn ) : NEW_LINE INDENT maxi = 0 NEW_LINE for i in range ( lenn ) : NEW_LINE INDENT maxi = max ( maxi , arr [ i ] ) NEW_LINE DEDENT ans = - 1 NEW_LINE for i in range ( 2 , maxi + 2 ) : NEW_LINE INDENT flag = True NEW_LINE for j in range ( lenn ) : NEW_LINE INDENT if ( arr [ j ] % i == 0 ) : NEW_LINE INDENT flag = False NEW_LINE break NEW_LINE DEDENT DEDENT if ( flag ) : NEW_LINE INDENT ans = i NEW_LINE break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 3 , 2 , 6 , 9 , 2 ] NEW_LINE N = len ( arr ) NEW_LINE smallestNumber ( arr , N ) NEW_LINE DEDENT