| home | contents | send comment | send link | add bookmark |

Factorial Numbers

by Stephen R. Schmitt

N = N! ≈

Contents

  1. About
  2. The source code
  3. Discussion

1. About

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


2. The source code

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


3. Discussion

For any positive integer N, the factorial is calculated by multiplying together all integers up to and including N, that is,

N! = N × (N - 1) × (N - 2) × . . . × 2 × 1
The first few factorials are:
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.

N! ≈ (2·π·N)1/2·NN·e-N + 1/(12·N)
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.

References

Eric W. Weisstein. "Stirling's Approximation." From MathWorld

Elementary Mathematical Analysis

Return to Contents


AbCd Classics - free on-line books


Copyright © 2004, Stephen R. Schmitt