Count the number of currency notes needed | Function to return the amount of notes with value A required ; If possible ; Driver Code
function bankNotes ( A , B , S , N ) { let numerator = S - ( B * N ) ; let denominator = A - B ; if ( numerator % denominator == 0 ) return ( Math . floor ( numerator / denominator ) ) ; return - 1 ; } let A = 1 , B = 2 , S = 7 , N = 5 ; document . write ( bankNotes ( A , B , S , N ) + " " ) ;