The value Euler number I am getting is 1.0

I tried what Luis sir talked about in class in python

f = lambda n: ((n + 1)/n) ** n

f(1e20)  # gives 1.0, not math.e

Also I used python because of it always growing nature in number (for example int here is bigger than int of C++)

Also mathematically when n is too big it approaches 0, which leaves 1^n and we all know what would be the value.

I tried with numpy and it is working

Try using 1.0 instead of 1, so that you have a floating point value in the equation.

Otherwise, you’re just doing integer division, and that always discards the fractional portion.

That’s why numpy exists. It’s better at math than standard Python.

1 Like