Find the Nth natural number which is not divisible by A | C ++ 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; void findNum ( int n , int k ) { int q = k / ( n - 1 ) ; int r = k % ( n - 1 ) ; int a ; if ( r != 0 ) a = ( n * q ) + r ; else a = ( n * q ) - 1 ; cout << a ; } int main ( ) { int A = 4 , N = 6 ; findNum ( A , N ) ; return 0 ; }