Count pairs of numbers from 1 to N with Product divisible by their Sum | Java program to 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
import java . io . * ; class GFG { static int countPairs ( int n ) { int count = 0 ; for ( int x = 1 ; x < n ; x ++ ) { for ( int y = x + 1 ; y <= n ; y ++ ) { if ( ( y * x ) % ( y + x ) == 0 ) count ++ ; } } return count ; } public static void main ( String [ ] args ) { int n = 15 ; System . out . println ( countPairs ( n ) ) ; } }