This Java Script calculator implements a spigot algorithm that generates a stream of digits that represent e, the base of the natural logarithms. Enter the number of digits desired after the decimal point and press the Compute button to write digits into 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
This calculator generates digits of the constant irrational number e using a spigot algorithm. e is the base number for natural logarithms. It has the property that the area under the hyperbola
| y = | 1 |
| x |
from x = 1 . . . e equals 1.
A spigot algorithm yields its outputs incrementally, and does not reuse them after producing them. The execution time of the algorithm grows with order N ². The number of executions of its innermost loop is given by:
| 10 N + | (N − 1) N |
| 2 |
where N is the number of digits generated by the algorithm after the decimal point.
References
[1] A spigot algorithm for the Digits of π; Stanley Rabinowitz and Stan Wagon; Am. Math. Monthly; March 1995; 195-203
[2] Tiny programs for constants computation; Xavier Gourdon and Pascal Sebah; May 28, 2003;
Return to Contents