not getting the print series question also what is n here in 3n+2
Print series question
Hello @kapilchaudhary706,
n is a natural number.
Let’s understand the question with an example:
Suppose you have given two inputs:
N1=3
N2=2
that means you have prints first N1(i.e.) terms of the series 3n + 2 which are not multiples of N2(i.e. 2).
starting n from 1…
for n=1,
31+2=5
5 is not a multiple of 2(i.e. N2), so print it.
for n=2,
32+2=8
8 is a multiple of 2(i.e. N2), so ignore it.
for n=3,
33+2=11
11 is not a multiple of 2(i.e. N2), so print it.
for n=4,
34+2=14
14 is a multiple of 2(i.e. N2), so ignore it.
for n=5,
3*5+2=17
17 is not a multiple of 2(i.e. N2), so print it.
Hence, you printed the first 3(i.e. N1) terms of this series that are multiple of 2(i.e. N2)
Stop further iteration.
Now, try to code the same logic.
Hint:
- Use the loop to increment the value of n
- Terminate loop until N1 is greater than 0
- decrement N1 when after printing a term.
Hope, this would help.
Give a like if you are satisfied,