What is wrong in my approach?

int main(){

int N1,N2;
cin>>N1>>N2;
int series;

for(int n=1;n<=N1;n++){
	series = 3n+2;
	if(series%N2 != 0){
	
	break;
	
	
}else {
cout<<series<<endl;
}

}

hello @anuragsen9617

a) u need to print total n1 terms that are not multiple of n2.
so iterating only upto n1 is not sufficient. we dont know upto how may iterations it will takr to print n1 terms so its better to use while loop.

b) u are using break, break statement will stop the loop execution but we dont want to stop ,instead we want to skip this for that use continue

refer this->

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.