Reply to thread

You can use template metaprogramming to speed up the computation of factorials.  This is advanced C++, though.

 

C++ Template Metaprogramming has an example.

 

If you are programming a more conventional factorial function, don't recurse or your stack may overflow.  Use a loop.  And make sure you don't overflow the int bounds and wind up with a garbage value.  n! gets very large very quickly.


Back
Top Bottom