Dec 21, 2010 at 7:55am UTC
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
Dec 21, 2010 at 8:41am UTC
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!
Last edited on
Dec 21, 2010 at 8:42am UTC
Dec 21, 2010 at 9:16am UTC
A simple factorial functions requires two lines, is it that much to write?
Dec 21, 2010 at 9:44am UTC
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.
Dec 21, 2010 at 10:02pm UTC
I'm talking about function implementation.
Even a + operation may give too large results. This doesn't mean that addition is not a trivial operation.
2-lines function is 2-lines function