custom input is working but test is not passing
Print series problem
first i have tried this one
#include
using namespace std;
void print(int n1, int n2){
int a=2;
int i=1;
int count=0;
while(i<=n1*n1){
if(a%n2!=0){
cout<<a<<endl;
if(count==n1){
break;
}
count++;
}
a+=3;
i++;
}
}
int main() {
int n1,n2;
cin>>n1>>n2;
print(n1,n2);
return 0;
}
then i have tried
#include
using namespace std;
void print(int n1, int n2){
long int a=2;
int i=1;
int count=0;
while(i<=3*101){
if(a%n2!=0){
cout<<a<<endl;
if(count==n1){
break;
}
count++;
}
a+=3;
i++;
}
}
int main() {
int n1,n2;
cin>>n1>>n2;
print(n1,n2);
return 0;
}
then
#include
using namespace std;
void print(int n1, int n2){
long int a=2;
int i=1;
int count=0;
for(int n = 0; n1 >= 0; n++)
{
int value = 3*n+2;
if (value % n2 != 0)
{
cout<<value<<endl;
n1–;
}
}
}
int main() {
int n1,n2;
cin>>n1>>n2;
print(n1,n2);
return 0;
}
all are giving correct custom input
but test cases are not passing
@sk3657860 hey sonu refer this
#include
using namespace std;
int main() {
int n1,n2;
cin>>n1>>n2;
int i=1;
while(i<=n1){
int ans=3*i+2;
if(ans%n2!=0){
cout<<ans<<endl;
}
else{
n1++;
}
i++;
}
}