Factorial in C++

Example for versions Borland C++ Builder 6, g++ 3.4.5

This example uses recursive factorial definition.

#include <iostream>

unsigned long long factorial(unsigned long long n)
{
	if (n == 0) 
		return 1;
	else 
		return n * factorial (n - 1);
}

int main(void)
{
    for (int n = 0; n <= 16; n++) 
        std::cout << n << "! = " << factorial(n) << std::endl;
    return 0;
}