Count of pairs of integers up to X and Y that generates equal Quotient and Remainder | C # Program for the above approach ; Function to calculate the number of pairs satisfying ( m / n = m % n ) ; Iterate from 1 to sqrt ( x ) ; Combining the conditions - 1 ) n > k 2 ) n <= y 3 ) n <= ( x / k - 1 ) ; Driver Code
using System ; public class GFG { static void countOfPairs ( int x , int y ) { int count = 0 ; for ( int k = 1 ; k * k <= x ; ++ k ) { count += Math . Max ( 0 , Math . Min ( y , x / k - 1 ) - k ) ; } Console . Write ( count ) ; } static public void Main ( ) { int x = 4 ; int y = 5 ; countOfPairs ( x , y ) ; } }