Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Find the factorial of a given number. More...
#include <cassert>
#include <iostream>
Namespaces | |
namespace | math |
for IO operations | |
Functions | |
uint64_t | math::factorial (uint8_t n) |
function to find factorial of given number | |
static void | tests () |
Self-test implementations. | |
int | main () |
Main function. | |
Find the factorial of a given number.
Calculate factorial via recursion
\[n! = n\times(n-1)\times(n-2)\times(n-3)\times\ldots\times3\times2\times1 = n\times(n-1)!\]
for example: \(5! = 5\times4! = 5\times4\times3\times2\times1 = 120\)
int main | ( | void | ) |
|
static |
Self-test implementations.