1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include <stdio.h>
// for: int printf(const char *, ...);

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

int
main(void)
{
    // 20! can be represented with 64 bits but 21! can not.
    for (unsigned long long n = 0; n < 21; ++n) {
        printf("%2llu! = %llu\n", n, factorial(n));
    }
}