Python: Computing $ e $ – Code Review Stack Exchange


First of all do not panic. 10 is just not enough. Try 20 and get it

2.71828182846

that is much closer.

Now, Python uses a native floating-point value that may only give you as many digits (for example, 30). To get more, you have to work with other representations. Fraktionen.Fraktion looks like a good candidate.

Finally he calls math.actorial Waste too much computing power. It is better to calculate faculties, eg.

                Nominal = 1
for i in the range (1, x):
e + = 1 / denom
Nominal value * = i