[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
Function factorial - determines a factorial (n!)
Syntax double factorial(int n);
Prototype in mathhk.h
Remarks factorial returns n! (1*2*3*...*n). Traditionally
seen as a recursive function used to illustrate
recursion, factorial is done with a loop, using no
recursion.
Return value returns n factorial (n! = 1*2*3*...*n). If n <= 1,
factorial returns 1. If the result of n! is larger
than MAXDOUBLE (the largest value a double can
store, defined in Borland's LIMITS.H), factorial
return zero.
See also summation()
Example #include <mathhk.h>
main()
{
double f;
if ((f = factorial(13)) == 0)
printf("Error computing 13!\n");
else
printf("13! = %15.0lf\n",factorial(13));
}
Program output 13! = 6227020800
See Also:
summation()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson