Print series given below

question is
Take the following as input.

A number (N1)
A number (N2)
Write a function which prints first N1 terms of the series 3n + 2 which are not multiples of N2.

my code-
#include
using namespace std;
int main() {
int n1,n2;
cin>>n1>>n2;
int a;
for(int i=0;i<n1;)
{a=((3*i)+2);
if(a%n2!=0)
cout<<a;
else
i++;
}
return 0;
}
cn someone tll me error in it

@9999082753 Your logic is going wrong in the loop. Dry run with any case and check it.
Loop should be something like this:
while(i<=n1)
{
if((3 * n+2)%n2!=0)
{
cout<<(3* n)+2<<endl;
i++;
}
n++;
}

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.