Count three | Function to count three - digit numbers having difference x with its reverse ; If x is not multiple of 99 ; No solution exists ; Generate all possible pairs of digits [ 1 , 9 ] ; If any pair is obtained with difference x / 99 ; Increase count ; Return the count ; Driver code
function Count_Number ( x ) { let ans = 0 ; if ( x % 99 != 0 ) { ans = - 1 ; } else { let diff = x / 99 ; for ( let i = 1 ; i < 10 ; i ++ ) { for ( let j = 1 ; j < 10 ; j ++ ) { if ( ( i - j ) == diff ) { ans += 10 ; } } } } return ans ; } let x = 792 ; document . write ( Count_Number ( x ) ) ;