Find numbers a and b that satisfy the given conditions | Function to print the required numbers ; Suppose b = n and we want a % b = 0 and also ( a / b ) < n so a = b * ( n - 1 ) ; Special case if n = 1 we get a = 0 so ( a * b ) < n ; If no pair satisfies the conditions ; Driver code
function find ( n ) { let b = n ; let a = b * ( n - 1 ) ; if ( a * b > n && a / b < n ) { document . write ( " " + a + " " + b ) ; } else document . write ( - 1 ) ; } let n = 10 ; find ( n ) ;