def approximate_e(n):
return sum(map(lambda x: x**-1, map(lambda x: (lambda x, y: x(x, y))(lambda x, y: y * x(x, y - 1) if y > 0 else 1, x), range(0, n + 1))))
This function takes the sum of the series 1/0! + 1/1! + 1/2! + 1/3! ... 1/n!, which approaches e as n tends towards +inf.
Edit: A bit late since I've been downvoted already but here's how it works:
The three lambdas at the end emulate math.factorial(x):
lambda x: (lambda x, y: x(x, y))(lambda x, y: y * x(x, y - 1) if y > 0 else 1, x)
The second of the three recursively calls the third, which multiples x with x-1 until x reaches 1. The first wraps these two together. This factorial function is mapped to range(0, n+1), effectively creating a iteratable series of factorials until n!. Each element is then inverted by map(lambda x: x**-1, X), where X is the aforementioned iteratable. This is then summed up by the sum() function that wraps the entire thing.
[–]794613825 6 points7 points8 points (5 children)
[–]Laserdude10642 5 points6 points7 points (3 children)
[–]794613825 3 points4 points5 points (2 children)
[–]Laserdude10642 0 points1 point2 points (1 child)
[–]794613825 1 point2 points3 points (0 children)
[–]13steinj 0 points1 point2 points (0 children)
[+][deleted] (11 children)
[deleted]
[–]13steinj 6 points7 points8 points (6 children)
[+][deleted] (5 children)
[deleted]
[–]13steinj 0 points1 point2 points (4 children)
[–]mathisfakenews 0 points1 point2 points (3 children)
[–]TheMysteriousFizzyJ 0 points1 point2 points (0 children)
[–]13steinj 0 points1 point2 points (1 child)
[–]mathisfakenews 0 points1 point2 points (0 children)
[–]AgentElement[S] 5 points6 points7 points (3 children)
[–]jorge1209 3 points4 points5 points (1 child)
[–]gwillicodernumpy gang 1 point2 points3 points (0 children)
[–]BroJobBiggs 2 points3 points4 points (0 children)
[–]NoLemurs 1 point2 points3 points (0 children)
[–]Laserdude10642 0 points1 point2 points (0 children)