Sounds like you need to create a function that will return the factorial of a given number. You can go with either a recursive or non-recursive solution to this.

After seeing Eric's response back to PJYelton's post re while loops: The non-recursive method below uses a while loop. I tested it on my machine and they both work from fact(0) through fact(12) = 479,001,600.

Recursive:
Code:
unsigned long fact( unsigned long n )
{
    if( n == 0 ) return 1;
    else if( n <= 2 ) return n;
    else return n * fact(n-1);
}
Non-recursive:
Code:
unsigned long fact( unsigned long n )
{
    unsigned long value = (n == 0) ? 1 : n;
    while( n >= 2 ) value *= --n;
    return value;
}