def approx_e(n): x=1 ecart=1 while ecart>1/10**n: x_n=(1+1/x)**x x_f=(1+1/x)**(x+1) ecart=x_f-x_n x+=1 return x,x_n,x_f