Marcin Kossakowski

Marcin Kossakowski

Tech and stuff

13 Oct 2013

Calculate Euler Number in Python

Here’s an example of how to calculate Euler number. The higher the number of iterations the more precise Euler number will be, but the time to compute it grows exponentially :) Learn more about Euler number

>>> a = 1.0
>>> for z in range(1, 100):
...     a += (1.0 / reduce(lambda x,y:x*y, [1]+range(1,z+1)))
>>> a
2.7182818284590455