The code for the iterative function factorial
is given below and in the file iterativeFactorial.cpp.
int factorial (int n)
{// Return n!.
if (n <= 1)
return 1;
int fact = 2;
for (int i = 3; i <= n; i++)
fact *= i;
return fact;
}