beetlebug▾
/

tcl::mathfunc gammaTcl 9.1 only

Gives the gamma function of a number.

tcl::mathfunc::gamma NUMBER
expr {gamma(NUMBER)}

Description

Gives the gamma function of NUMBER, so gamma(N) is the factorial of N-1 for a whole N. gamma(0) is Inf, and a negative whole number is a domain error. It is tgamma of C.

Arguments

ArgumentTypeDefaultDescription
NUMBERnumberrequiredAny number except a negative whole number.

Returns

A float.

Examples

% expr {gamma(5)}
24.0

% expr {gamma(0.5)}
1.7724538509055159

% expr {gamma(-1.5)}
2.363271801207354

% expr {gamma(0)}
Inf

Errors

% expr {gamma(-1)}
domain error: argument not in valid range
-errorcode ARITH DOMAIN {domain error: argument not in valid range}

% expr {gamma("x")}
expected floating-point number but got "x"
-errorcode TCL VALUE NUMBER

Facts

Capability
None.
Tcl release
Tcl 9.1 only.
Since
ztcl 1.0.0-beta.1

See also