Count of numbers upto M divisible by given Prime Numbers | Function to count the numbers that are divisible by the numbers in the array from range 1 to M ; Initialize the count variable ; Iterate over [ 1 , M ] ; Iterate over array elements arr [ ] ; Check if i is divisible by a [ j ] ; Increment the count ; Return the answer ; Given list lst ; Given number M ; Function call
def count ( a , M , N ) : NEW_LINE INDENT cnt = 0 NEW_LINE for i in range ( 1 , M + 1 ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT if ( i % a [ j ] == 0 ) : NEW_LINE INDENT cnt += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT return cnt NEW_LINE DEDENT lst = [ 2 , 3 , 5 , 7 ] NEW_LINE m = 100 NEW_LINE n = len ( lst ) NEW_LINE print ( count ( lst , m , n ) ) NEW_LINE