|
|
|
|
|
by arbre
3841 days ago
|
|
You can also compute the factorials at compile time with templates: template<int64_t n> int64_t fact() { return n * fact<n-1>(); }
template<> int64_t fact<0>() { return 1; } The book "Modern C++ design" from Alexandrescu extensively covers that kind of stuff. There might even be a way to use a loop and constexprs. |
|