#include
using namespace std;
int main(){
int N1,N2;
cin>>N1>>N2;
int n = 1 ;
int ans;
int count = 0;
while(count <= N1){
ans = 3*n+2;
n= n+1;
count = count +1;
if(ans%N2!=0){
cout<<ans<<endl;
}
}
return 0;
}
#include
using namespace std;
int main(){
int N1,N2;
cin>>N1>>N2;
int n = 1 ;
int ans;
int count = 0;
while(count <= N1){
ans = 3*n+2;
n= n+1;
count = count +1;
if(ans%N2!=0){
cout<<ans<<endl;
}
}
return 0;
}
Refer this. Code it by yourself.
If there is some error then please save your code on ide.codingblocks.com and then share its link.
i have saved my code on ide but on going to share option i am not getting the link
here is the link i got on the url
Check now.
still showing some test cases wrong
Please paste the problem statement here with constraints and sample outputs so that i can check.
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.
Input Format
Constraints
0 < N1 < 100 0 < N2 < 100
Output Format
Sample Input
10
4
Sample Output
5
11
14
17
23
26
29
35
38
41
Explanation
The output will’ve N1 terms which are not divisible by N2.
and please explain my error
Check now.
Note that we need to print terms starting from n = 1 in the given series (3n + 2) … so n must be initialized with 1.