On , Carlton Walters (1:250/536@fidonet) wrote:
> write a program that calculate the factorial of a entered integer.
> I did this before but I forget.
Carlton...
It's in SNIPPETS - see FACTORYL.C. Note, however, that if you're trying to
crib a homework assignment, this isn't the code for you. Homework
assignements typically as for either a recursive or non-recursive solution
(or both, since the algorithm's trivial). The SNIPPETS function is more
useful for real-life use since it returns the Log10 of the factorial rather
than the value itself. Anything greater than 69! will overflow a typical
pocket calculator which only goes up to 9.99...e+99. Your average C library,
using doubles, can go as high can as 1.797...e+308, which will suffice to
calculate only up to 170!
The SNIPPETS version, OTOH, can easily be used to calculate things like
permutations of 750,000 elements out of 1,000,000 - in fact the built in test
harness does this as a demo.
--- QM v1.00
---------------
* Origin: MicroFirm : Down to the C in chips (1:106/2000.6)
|