Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/simplestatistics/src/gamma.js>default

simple statistics for node & browser javascript
Latest
function default
import { default } from "https://deno.land/x/simplestatistics@v7.8.3/src/gamma.js";

Compute the gamma function of a value using Nemes' approximation. The gamma of n is equivalent to (n-1)!, but unlike the factorial function, gamma is defined for all real n except zero and negative integers (where NaN is returned). Note, the gamma function is also well-defined for complex numbers, though this implementation currently does not handle complex numbers as input values. Nemes' approximation is defined here as Theorem 2.2. Negative values use Euler's reflection formula for computation.

Examples

gamma(11.5); // 11899423.084037038 gamma(-11.5); // 2.29575810481609e-8 gamma(5); // 24

Parameters

n

Any real number except for zero and negative integers.