This site is supported by donations to The OEIS Foundation.

Template:Factorial

From OeisWiki

Jump to: navigation, search
The following documentation is located at Template:Factorial/doc. [Edit Template:Factorial/doc]
[<Purge> Template:Factorial]

The {{factorial}} mathematical function template returns \scriptstyle n! \,, the factorial of \scriptstyle n \,, for nonnegative integers \scriptstyle n \, in [0..16], otherwise returns an error message. (For \scriptstyle n \,\ge\, 17 \,, the returned value would not be an exact integer but only an approximation with a floating point number representation.) This template works by repeating conditional multiplications.

Contents

Usage

{{factorial|input}}

or

{{fact|input}}

or

{{n!|input}}

Valid input

Returns \scriptstyle n! \, for a nonnegative integer \scriptstyle n \, in [0..16] (worse than most calculators, which go up to 69!, although only as an approximation with a floating point number representation), otherwise returns an error message.

Examples

Examples with valid input (returns \scriptstyle n! \,)

Code Result Code Result
{{factorial|0}} 1   {{fact|0}} 1
{{factorial|1}} 1   {{fact|2}} 2
{{factorial|2}} 2   {{fact|2}} 2
{{n!|3}} 6   {{n!|4}} 24
{{n!|5}} 120   {{n!|6}} 720
{{n!|7}} 5040   {{n!|8}} 40320
{{n!|9}} 362880   {{n!|10}} 3628800
{{n!|11}} 39916800   {{n!|12}} 479001600
{{n!|13}} 6227020800   {{n!|14}} 87178291200
{{n!|15}} 1307674368000   {{n!|16}} 20922789888000


Examples with invalid input (returns an error message)

Code Result
{{n!|17}} Factorial error: Argument must be a nonnegative integer up to 16
{{n!|80}} Factorial error: Argument must be a nonnegative integer up to 16
{{n!|-1}} Factorial error: Argument must be a nonnegative integer up to 16
{{n!|0.5}} Factorial error: Argument must be an integer
{{n!|text}} Factorial error: Argument must be an integer
{{n!|6 blobs}} Factorial error: Argument must be an integer

Code

Cf. {{Factorial/test#Code}}.

Test

Cf. {{Factorial/test}}.

See also

Personal tools