Returns the factorial based on the gamma function.
double factorial(num n) => n < 0.0 ? double.nan : gamma(1.0 + n);