Factorial in Pike

Example for versions Pike 7.8

This example uses recursive factorial definition. Note that int data type is extended to bignum in case of overflow.

int factorial(int n) 
{
    return ( n<=1 ? 1 : n * factorial(n-1) );
}

void main() 
{
    for (int n=0; n<=16; n++)
        write(n+"! = "+factorial(n)+"\n");
}