0
How to print this series Using One Loop.
Input 1 : 3 Output : 0 1 2 3 2 1 0 Input 2 : 5 Output : 0 1 2 3 4 5 4 3 2 1 0
4 Answers
+ 3
Always show attempts with question so it would be easy to tell mistake.
Here it is in C++ you can try in other language too.
https://code.sololearn.com/cbKSN6WxqcjV/?ref=app
+ 3
Minhaj Haider(MiDer) the sequence has the pattern of an absolute value function,
n - abs(i)
Now you can work out the single loop conditions of index i that will print the desired output. What starting and ending values of i will both give you zero?
+ 1
A͢J thank you sir
+ 1
Brian thanks sir