0
Multiplying sequence.
I'm using C++ for this, i'm wanting to be able to input a number, say 5,and output the answer of 5*4*3*2*1. how would I go about doing this?
2 ответов
+ 1
a general approach...
not in any specific language
a=5
for i from 5 to 1
a=a*i
or
a=5
for i from 1 to 5
a=a*i
or
function factorial(argument):
if argument==1 then return 1
else return argument*factorial(argument-1)
//calling the func.
factorial(5)
0
Thank you!