Sum of array elements which are multiples of a given number | Function to find the sum of array elements which are multiples of N ; Stores the sum ; Traverse the array ; Print total sum ; Driver Code ; Given arr [ ] ; Function call
def mulsum ( arr , n , N ) : NEW_LINE INDENT sums = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if arr [ i ] % N == 0 : NEW_LINE INDENT sums = sums + arr [ i ] NEW_LINE DEDENT DEDENT print ( sums ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 5 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE N = 3 NEW_LINE mulsum ( arr , n , N ) NEW_LINE DEDENT