std factorial function

Is there a factorial function defined in a header file someplace in *nix or c/c++
I don't want to have to write this anytime i need it, kind of annoying

all googles report a bunch of noobie problems
Nope. At least, not as far as I know of. If anywhere, it would be in <cmath>, but I didn't see it there.

You can write your own function and copy it to a file where you can easily find it, though!

-Albatross
Last edited on
A simple factorial functions requires two lines, is it that much to write?
I mean isn't that the point of a function...
I realized that i actually needed nCm.
I actually can't recall anytime I have actually needed to compute a factorial besides class assignments.
Perhaps this is why it's not in a standard header and Bazzy's point is quite valid.
 A simple factorial functions requires two lines, is it that much to write?

Nope, a simple factorial (such as, for example, 25!), takes more than 64 bits of space when represented as a number. So, even simple factorials such as 25! are not that easy to realize.
 ``1234`` ``````int factorial(int n) { return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n; }``````