Count numbers less than N whose modulo with A is equal to B | Function to count numbers less than N , whose modulo with A gives B ; If the value of B at least A ; If the value of B is 0 or not ; Stores the resultant count of numbers less than N ; Update the value of ans ; Print the value of ans ; Driver Code
function countValues ( A , B , C ) { if ( B >= A ) { document . write ( 0 ) ; return ; } if ( B == 0 ) { document . write ( parseInt ( C / A ) ) ; return ; } let ans = parseInt ( C / A ) ; if ( ans * A + B <= C ) { ans ++ ; } document . write ( ans ) ; } let A = 6 , B = 3 , N = 15 ; countValues ( A , B , N ) ;