Print series 3n+2

take input two numbers n1 and n2 . print series 3n+2 having n1 terms and no term is devisible by n2 .
how to make sure output has n1 terms ??
#include

using namespace std;

int main(){
int N1 , N2 , a , n ;
cin>>N1 ;
cin>>N2 ;
n = 1 ;

while(n<=N1){
    a = 3*n + 2 ;
    
    if(a%N2 != 0){
        cout<<a<<endl;
    }
    n = n + 1 ;
}

}

what you can do is maintain a count of output terms suppose you N1 is 5, so until and unless your output gives count of 5, don’t break the while loop let it be continue. Just implement this logic cause rest of your code is correct. And please share your code using ide.codingblocks.com cause it makes easy for us to let you know your mistake. If you still can’t find your mistake i can provide you with the solution. But i would suggest you to try it first and share your updated code also with me :smile: