Finding 10000 decimals of e

Up a level : Algebra and Arithmetic
Previous page : Numbers, an introduction
Next page : Finding 10000 decimals of pi

In the following pages 10 000 decimals of e are calculated using the standard series expansion formula. The calculations are done using JavaScripts native bigInt value type, but interpreted as fixed int numbers, where 1 is replaced by a value 10 to the power of some number. In this way all the calculations can be done using integers only. When printing out the result the decimal point is added.

The actual calculation is not more than this:

do {
  i++;
  f *= i;
  q = tenEn / f;
  e += q;
} while (q > 0);

 

The value of i is initially 1, and the same with f. The value tenEn = 1010005, and that value is now our 1.
In each turn of the loop i is increased by one, then f is multiplied by i to get successive factorials, then “one”/the factorial is added to the approximation of e. The loop stops when what we add is 0, i.e. when the factorial is > tenEn.
Up a level : Algebra and Arithmetic
Previous page : Numbers, an introduction
Next page : Finding 10000 decimals of piLast modified: Jun 15, 2021 @ 21:11