Check if sum of arr [ i ] / j for all possible pairs ( i , j ) in an array is 0 or not | Function to check if sum of all values of ( arr [ i ] / j ) for all 0 < i <= j < ( N - 1 ) is 0 or not ; Stores the required sum ; Traverse the array ; If the sum is equal to 0 ; Otherwise ; Driver Code
function check ( arr , N ) { var sum = 0 ; for ( i = 0 ; i < N ; i ++ ) sum += arr [ i ] ; if ( sum == 0 ) document . write ( " " ) ; else document . write ( " " ) ; } var arr = [ 1 , - 1 , 3 , - 2 , - 1 ] ; var N = arr . length ; check ( arr , N ) ;