I am stuck in the code of printing series . I have written the code and tried may times , but I was unable to find the bug , will you please help me to find its solution

#include
using namespace std;
int main()
{
int j,k;
int n1,n2;
cin>>n1>>n2;
int n=1;
for(int j=1;j<=(n1+(n2-1));j++)
{
k=3*n+2;
if(k%n2==0)
{

            n++;
           // break;
        }
        else{
			cout<<k<<endl;
            n++;
           // break;
           
        }
       
    }
    // cout<<"k"<<endl;
// }
return 0;

}

hi @deepshreyamishra301_1918130c8477386b,
please check for this test case
10 2
ans is :
5
11
17
23
29
35
41
47
53
59

@deepshreyamishra301_1918130c8477386b refer here ive commented https://ide.codingblocks.com/s/659264

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.