For a positive $\varepsilon$, how do you find $n$ that satisfies $e-\left(1+ \frac{1}{n}\right)^n<\varepsilon$?
Below is the context.
Definition
$$e=\lim_{n\rightarrow\infty}\left(1+ \frac{1}{n}\right)^n$$
Attempt
It is proved that $e=1+1+\frac{1}{2!}+\frac{1}{3!}+\dots$. On the other hand, $\left(1+ \frac{1}{n}\right)^n = 1+1+\left(1-\frac{1}{n}\right)\frac{1}{2!}+\left(1-\frac{1}{n}\right)\left(1-\frac{2}{n}\right)\frac{1}{3!}+\dots+\left(1-\frac{1}{n}\right)\dots\left(1-\frac{n-1}{n}\right)\frac{1}{n!}$.
So,
$$\begin{aligned} e-\left(1+ \frac{1}{n}\right)^n &= \sum_{k=1}^n \left( 1 - \prod_{i=1}^k \left(1-\frac{i}{n}\right)\right)\frac{1}{(k+1)!} +r(n)\\ &<\sum_{k=1}^n \left( 1 - \left(1-\frac{k}{n}\right)^{k}\right)\frac{1}{(k+1)!} + r(n) \end{aligned}$$
$r(n)$ can be evaluated using Taylor's theorem. The problem is to find $n$ which satisfies $\sum_{k=1}^n \left( 1 - \left(1-\frac{k}{n}\right)^{k}\right)\frac{1}{(k+1)!}<\varepsilon$.
Motivation and where the question comes from
This is a natural question. It is normal to evaluate the error for all limits.
My background
Undergraduate.
This is an alternate way to derive an $n$ that works, reasonable close to the optimal one given in Claude Leibovici's answer, without using any special function.
Notice for $x > 0$, $$\left(\frac1x\right)' = -\frac1{x^2} < 0\quad\text{ and }\quad \left(\frac1x\right)'' = \frac{2}{x^3} > 0$$ $\frac1x$ is strictly decreasing and strictly convex over $(0,\infty)$. This implies for any $n > 0$, its integral over $[n,n+1]$ is sandwiched between its values at lower end and midpoint. i.e $$ \frac1n > \int_n^{n+1} \frac{dx}{x} = \log\left(1 + \frac1n\right) >\frac{1}{n+\frac12}$$ This is equivalent to $$\left(1+\frac1n\right)^n < e < \left(1+\frac1n\right)^{n+\frac12}$$ From this, we can deduce $$0 < e - \left(1+\frac1n\right)^n < \left(1+\frac1n\right)^n\left(\sqrt{1+\frac1n}-1\right) < \frac{e}{2n}$$ This implies for any integer $n \ge \left\lceil \frac{e}{2\epsilon}\right\rceil$, we will have $0 < e - \left(1+\frac1n\right)^n < \epsilon$.