#include <inttypes.h>
#include <xtend/math.h>
-lxtend
uint64_t xt_factorial(unsigned n)
n Integer in the range [0,20] (inclusive) for which n! is returned.
Instantaneous factorial for n in [0,20] using a lookup table.
Note that 21! is beyond the range of uint64_t, so programs that
need it should either use a multiple precision library or rearrange the
computations to avoid repeated multiplication leading to overflow.
n_choose_k(3) uses the latter approach to avoid computing whole factorials
before finally dividing.
n! if n is an element of [0,20], 0 otherwise
#include <inttypes.h>
#include <xtend/math.h>
printf("20! = %" PRIu64 "n", factorial(20));