TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Find the factorial of a given number. More...
#include <cassert>
#include <cstdint>
#include <iostream>
Go to the source code of this file.
Namespaces | |
namespace | math |
for assert | |
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\)
Definition in file factorial.cpp.
int main | ( | void | ) |
|
static |
Self-test implementations.
Definition at line 44 of file factorial.cpp.