! - Maple Programming Help

Home : Support : Online Help : Mathematics : Numbers : Integer Functions : factorial

!

compute factorial

factorial

compute factorial

doublefactorial

compute double factorial

 Calling Sequence m! factorial(m) doublefactorial(n)

Parameters

 m - expression, not a negative integer n - integer greater than or equal to $-1$

Description

 • The m! and factorial(m) commands return the factorial of m.
 If m is a positive integer, Maple returns the product of the numbers from 1 to m. If m is $0$ (zero), Maple returns $1$ (one).
 If m is a (real or complex) floating-point number,  Maple returns the generalized factorial function result calculated using GAMMA(m+1).
 If m is a negative integer, Maple returns an error.
 • The doublefactorial(n) command returns the double factorial of n, defined in terms of the generalized factorial as
 > FunctionAdvisor( definition, doublefactorial );
 $\left[{\mathrm{doublefactorial}}{}\left({n}\right){=}{{2}}^{\frac{{n}}{{2}}}{}{\left(\frac{{2}}{{\mathrm{\pi }}}\right)}^{\frac{{1}}{{4}}{-}\frac{{\mathrm{cos}}{}\left({\mathrm{\pi }}{}{n}\right)}{{4}}}{}\left(\frac{{n}}{{2}}\right){!}{,}{\mathrm{with no restrictions on}}{}\left({n}\right)\right]$ (1)
 When n is a positive integer, this definition is equivalent to the product:
 • $n\left(n-2\right)\mathrm{...}\left(6\right)\left(4\right)\left(2\right)$ if n is an even, positive integer
 • $n\left(n-2\right)\mathrm{...}\left(5\right)\left(3\right)\left(1\right)$ if n is an odd, positive integer
 Note: In Maple, !! is used for repeated factorials and so it does not indicate the double factorial.
 • The type function perceives the factorial function as of type function and as of type "!", while it perceives doublefactorial as of type function only.
 • The internal representation of an unevaluated factorial uses the standard representation of functions, with the function name factorial. Thus to the op function, the 0th operand of $m!$ is factorial.

Examples

 > $5!=\mathrm{\Gamma }\left(6\right)$
 ${120}{=}{120}$ (2)
 > $3.5!$
 ${11.63172840}$ (3)
 > $m!$
 ${m}{!}$ (4)

The factorial of a negative integer cannot be calculated. The function GAMMA(m+1) is used to calculate the factorial of a floating point number, real or complex.

 > $\left(-2\right)!$
 > $\left(-2.1\right)!$
 ${9.714806383}$ (5)
 > $\left(-3.I\right)!$
 ${0.01929275896}{-}{0.03389601054}{}{I}$ (6)

The doublefactorial(n) command is not the same as !!. There are no restrictions on the value of n because of the way the function is defined.

 > $\mathrm{doublefactorial}\left(5\right)$
 ${15}$ (7)
 > $\left(5!\right)!$
 ${6689502913449127057588118054090372586752746333138029810295671352301633557244962989366874165271984981308157637893214090552534408589408121859898481114389650005964960521256960000000000000000000000000000}$ (8)
 > $\mathrm{doublefactorial}\left(10\right)$
 ${3840}$ (9)
 > $\mathrm{doublefactorial}\left(-7\right)$
 ${-}\frac{{1}}{{15}}$ (10)
 > $\mathrm{doublefactorial}\left(1.+2.I\right)$
 ${3.636406167}{}{{10}}^{{-14}}{+}{4.100313151}{}{{10}}^{{-14}}{}{I}$ (11)

The 0th operand of m! is factorial.

 > $\mathrm{type}\left(m!,\mathrm{function}\right)$
 ${\mathrm{true}}$ (12)
 > $\mathrm{type}\left(m!,\mathrm{!}\right)$
 ${\mathrm{true}}$ (13)
 > $\mathrm{op}\left(0,m!\right)$
 ${\mathrm{factorial}}$ (14)
 >