How can I print this series 1 -6 120 -5040 when user input n=7. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can I print this series 1 -6 120 -5040 when user input n=7.

Read the value of an N and print the series , 1 -3 5 -7...N int n, x=1; For(int I=1;I<=n;I +=2) { Printf("%d",I*x); x*=(-1); } But I'm not know how can I print this series For N=7 output is the following series , 1 -6 120 -5040 It's like Factorial Number.

25th Apr 2023, 9:17 AM
Ayesha
Ayesha - avatar
6 Answers
+ 2
Here's a factorial list from 1 ~ 7 # 1 2 3 4 5 6 7 F 1 2 6 24 120 720 5040 Notice that you need to skip printing factorial of even numbers, and invert negative sign on each printed factorial number.
25th Apr 2023, 2:59 PM
Ipang
+ 9
Ayesha where is your attempt?
25th Apr 2023, 10:16 AM
Sakshi
Sakshi - avatar
+ 3
Is that 1 followed by -6 (negative six) then 120 followed by -5040 (negative 5040) Or one to six, then 120 to 5040 Do they print on one line or separate line? Please elaborate more by editing the post with additional details in post Description.
25th Apr 2023, 11:16 AM
Ipang
+ 3
Hadn't you tried yet 🤔
25th Apr 2023, 2:34 PM
Hasnain [ACTIVE CHALLENGER]
Hasnain [ACTIVE CHALLENGER] - avatar
+ 2
Show your attempt
25th Apr 2023, 10:51 AM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
+ 2
looks like you just need to take the factorial of each result from the first series, while still keeping the sign step until last, no? Should be a fairly straightforward nested loop situation once you've gotten this far, so what's the problem you're having?
25th Apr 2023, 2:34 PM
Orin Cook
Orin Cook - avatar