Show DevBest [C] Factorial function

Status
Not open for further replies.

Pro123

New Member
Feb 20, 2011
21
0
Yes, another silly function. This time it finds the factorial of a number.

Code:
factorial(number);



Code:
long factorial(long x)
{
    long factorial = x;
    long i = 0;
    
    for (i = (x - 1); i > 1; --i)
    {
        factorial = (factorial * i);
    }
    
    return factorial;
}
 
Status
Not open for further replies.

Users who are viewing this thread

Top