...

View Full Version : Explain Function Factorial()



Jus S
11-11-2008, 06:36 AM
Can someone break this down for me so I can understand what a factorial does?

I'm working with C and what I read doesn't make sense to me.

oesxyl
11-11-2008, 06:56 AM
Can someone break this down for me so I can understand what a factorial does?

I'm working with C and what I read doesn't make sense to me.
factorial(n) compute the product of all numbers from 1 to n:



factorial(3) = 1*2*3
factorial(4) = 1*2*3*4
factorial(7) = 1*2*3*4*5*6*7


probably you learn about recursivity and need one of his property:



factorial(n) = n * factorial(n-1);


best regards

jmac555
11-12-2008, 08:44 AM
Just in case you were wondering what some applications of the Factorial function are, in maths n! (factorial) returns the number of ways that n number of objects can be arranged. For example there are 7 possibilities that can go in the first place, then 6 that can go in the second spot, and so forth.
Hope this helped
happy coding.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum