OK...
first think about what a factorial is...
Quote:
1! = 1 = 1
2! = 2 x 1 = 2
3! = 3 x 2 x 1 = 6

so to find a factorial number you need to multiply all the numbers below it in sequence until you get to the at number...
for instance 4! = 1 * 2 * 3 * 4 = 24
so you just need a simple loop,
n = [start number];
factorial = 1;
for (i=1;i<=n;i++)
{
factorial = factorial * i;
}
n is the number that you start with
factorial is the total...
put the number 5 into the loop and you get something like...
n=5
(i=1) (factorial=1) > (new factorial = 1*1 = 1)
(i=2) (factorial=1) > (new factorial = 1*2 = 2)
(i=3) (factorial=2) > (new factorial = 2*3 = 6)
(i=4) (factorial=6) > (new factorial = 6*4 = 24)
(i=5) (factorial=24) > (new factorial = 24*5 = 120)
now i=t so the loop stops and you have the numbers...
n=5
factorial = 120.
__________________