For the sample inputs(10,4) it is showing one extra output. Please guide

#include
using namespace std;
int main() {
int n,N1,N2,S,count=0;
cin>>N1;
cin>>N2;
n=1;

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



}
return 0;

}

hi @sbhardwaj1be21_2a991b329433c059 write < not <= in while loop as count is starting from 0

1 Like