Yes, another silly function. This time it finds the factorial of a number.
Usage:
Code:
Please be aware that any input number greater than 31 will not produce a useful result. This is because long integers cannot store numbers greater than the factorial of 31. Sorry.
Usage:
Code:
factorial(number);
Code:
Code:
long factorial(long x)
{
long factorial = x;
long i = 0;
for (i = (x - 1); i > 1; --i)
{
factorial = (factorial * i);
}
return factorial;
}
Please be aware that any input number greater than 31 will not produce a useful result. This is because long integers cannot store numbers greater than the factorial of 31. Sorry.