There was an error while loading. Please reload this page.
1 parent 46b4ce1 commit 30b8c6eCopy full SHA for 30b8c6e
Lecture 6: Operators and For Loop/Assignment/Terms of AP
@@ -0,0 +1,38 @@
1
+Write a program to print first x terms of the series 3N + 2 which are not multiples of 4.
2
+Input format :
3
+Integer x
4
+Output format :
5
+Terms of series (separated by space)
6
+Constraints :
7
+1 <= x <= 1,000
8
+Sample Input 1 :
9
+10
10
+Sample Output 1 :
11
+5 11 14 17 23 26 29 35 38 41
12
+Sample Input 2 :
13
+4
14
+Sample Output 2 :
15
+5 11 14 17
16
+
17
18
+CODE:
19
20
+#include<iostream>
21
+using namespace std;
22
23
+int main() {
24
+// Write your code here
25
+ int n;
26
+ cin>>n;
27
+ int i,term;
28
+ int count=1;
29
+ for(i=1; count<=n; i++){
30
+ term=3*i+2;
31
+ if(term%4!=0){
32
+ cout<<term<<" ";
33
+ count++;
34
+ }
35
36
37
38
+}
0 commit comments