Find Nth number in a sequence which is not a multiple of a given number | Function to find Nth number not a multiple of A in range [ L , R ] ; Calculate the Nth no ; Check for the edge case ; Input parameters ; Function Call
function countNo ( A , N , L , R ) { var ans = L - 1 + N + Math . floor ( ( N - 1 ) / ( A - 1 ) ) ; if ( ans % A == 0 ) { ans = ans + 1 ; } document . write ( ans ) ; } var A = 5 , N = 10 , L = 4 , R = 20 ; countNo ( A , N , L , R ) ;