Count pairs of numbers from 1 to N with Product divisible by their Sum | Function to count pairs ; variable to store count ; Generate all possible pairs such that 1 <= x < y < n ; Driver code
function countPairs ( n ) { let count = 0 ; for ( let x = 1 ; x < n ; x ++ ) { for ( let y = x + 1 ; y <= n ; y ++ ) { if ( ( y * x ) % ( y + x ) == 0 ) count ++ ; } } return count ; } let n = 15 ; document . write ( countPairs ( n ) ) ;