Download Tutorial C Files H Files

dg_factorial

This function calculate the factorial of a number by n.

Usage

int dg_factorial(int n);

Example

int dg_factorial(5);

Source code

int dg_factorial(int n)
{
    int result = 1;

    for (int i = 2; i <= n; i++)
        result *= i;
    return result;
}