Find the Nth natural number which is not divisible by A | Javascript code to Find the Nth number which is not divisible by A from the series ; Find the quotient and the remainder when k is divided by n - 1 ; If the remainder is not 0 multiply n by q and subtract 1 if remainder is 0 then multiply n by q and add the remainder ; Print the answer ; Driver code
function findNum ( n , k ) { let q = parseInt ( k / ( n - 1 ) ) ; let r = k % ( n - 1 ) ; let a ; if ( r != 0 ) a = ( n * q ) + r ; else a = ( n * q ) - 1 ; document . write ( a ) ; } let A = 4 , N = 6 ; findNum ( A , N ) ;