Check if there is any pair in a given range with GCD is divisible by k | function to count such possible numbers ; if i is divisible by k ; if count of such numbers is greater than one ; Driver code
class GFG { public boolean Check_is_possible ( int l , int r , int k ) { int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { if ( i % k == 0 ) { count ++ ; } } return ( count > 1 ) ; } public static void main ( String [ ] args ) { GFG g = new GFG ( ) ; int l = 4 , r = 12 ; int k = 5 ; if ( g . Check_is_possible ( l , r , k ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }