## iop360 3 years ago how to write a factorial in C++

• This Question is Open
1. ammar-93

factorial !! explain more plz !!!

2. iop360

3 factorial = 3! = (3*2*1)

3. iop360

so say i want $\frac{ x^3 }{ 3! }$

4. iop360

is there an operator for that

5. iop360

or would i just type it out as (3*2*1)

6. ammar-93

I got it , I'll explain the algorithm : we can write a loop like this : for i is from x to 1 then : x! = x * (x-1)

7. iop360

ok

8. iop360

how would i write this

9. iop360

most efficiently

10. ammar-93

for example .. to calc 5! : for i= 1 to 5 do x!=x(x-1) is it clear ?

11. iop360

is that all you would type

12. iop360

what does i mean

13. ammar-93

I'm sorry I'll not write the code to you , I've told you the idea and U've to try ... good luck

14. iop360

ok thanks

15. eSpeX

@iop360 Try writing the steps out by hand, then look at the process you used and replicate it in your code.