Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
Math code snippet to calculate a factorial.
There are multiple ways to calculate a factorial:
Using a for-loop withing the function.
#include <cassert> |
#include <cassert> |
The code belows shows a way how to use algorithms to calculate a factorial. This is not the preferred option.
#include <functional> |
With compile-time checking using a template version of assert.
template <bool> |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.