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 given array ; If current element is a multiple of N ; Print total sum ; Given arr [ ]
function mulsum ( arr , n , N ) { var sum = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % N == 0 ) { sum = sum + arr [ i ] ; } } document . write ( sum ) ; } var arr = [ 1 , 2 , 3 , 5 , 6 ] ; var n = arr . length ; var N = 3 ; mulsum ( arr , n , N ) ;