Factorial
This algorithm finds the factorial of a given number.
/*****Please include following header files*****/
// cstdint
/***********************************************/
int64_t Factorial(int number) {
if (number < 0)
return -1; //Error
int64_t result = 1;
for (int i = 1; i <= number; ++i)
result *= i;
return result;
}
Example
int64_t factorial = Factorial(10);
Output
3628800