This Java Script calculator generates the digits of factorial numbers. To operate the calculator, enter the number. Press the Compute button to obtain the solution. Stirling's approximation is displayed on this page. For large values, the approximate value may exceed your machine's capacity to represent floating point numbers. In this case the approximate value will be displayed as Infinity. The exact value is displayed in a separate window. On invalid entries, a popup window will display an error message.
Return to Contents
The Java Script source code for this program can be viewed by using the View|Source command of your web browser.
You may use or modify this source code in any way you find useful, provided that you agree that the author has no warranty, obligations or liability. You must determine the suitability of this source code for your use.
Return to Contents
For any positive integer N, the factorial is calculated by multiplying together all integers up to and including N, that is,
The first few factorials are:N! = N × (N - 1) × (N - 2) × . . . × 2 × 1
0! = 1 note! 1! = 1 2! = 2 3! = 6 4! = 24 5! = 120 6! = 720 7! = 5040 8! = 40320 9! = 362880
Factorials start out reasonably small but grow extremely rapidly. An approximation, named after the Scottish mathematician James Stirling (1692-1770), can be used in a computer to approximate N factorial.
To calculate an exact value, there is no shortcut formula; all of the multiplications must be done explicitly. This JavaScript calculator gives the exact value of N! for large values of N.N! ≈ (2·π·N)1/2·NN·e-N + 1/(12·N)
References
Eric W. Weisstein. "Stirling's Approximation." From MathWorld
Elementary Mathematical Analysis
Return to Contents
AbCd Classics - free on-line books