This site is supported by donations to The OEIS Foundation.
Template:Factorial
From OeisWiki
[<Purge> Template:Factorial]
The {{factorial}} mathematical function template returns
, the factorial of
, for nonnegative integers
in [0..16], otherwise returns an error message. (For
, 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
for a nonnegative integer
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
)
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
- {{factorial}} or {{fact}} or {{n!}}
- {{Pochhammer}} or {{Poch}} or {{x^(n)}}
