![]() |
TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Iterative implementation of Factorial More...
#include <cassert>#include <cstdint>#include <exception>#include <iostream>Go to the source code of this file.
Namespaces | |
| namespace | math |
| for assert | |
Functions | |
| uint64_t | math::iterativeFactorial (uint8_t n) |
| Calculates the factorial iteratively. | |
| static void | test () |
| Self-test implementations to test iterativeFactorial function. | |
| int | main () |
| Main function. | |
Iterative implementation of Factorial
Calculates factorial iteratively.
\[n! = n\times(n-1)\times(n-2)\times(n-3)\times\ldots\times3\times2\times1 = n\times(n-1)!\]
for example: \(4! = 4\times3! = 4\times3\times2\times1 = 24\)
Definition in file iterative_factorial.cpp.
| int main | ( | void | ) |
Main function.
Definition at line 120 of file iterative_factorial.cpp.
|
static |
Self-test implementations to test iterativeFactorial function.
Definition at line 69 of file iterative_factorial.cpp.