标签: c
答案 0 :(得分:1)
使用代数和e函数定义,|e(n) - e(n+1)| < x可以简化为(1/n!) < x,可以扩展为(1/1) * (1/2) * (1/3) * ... * (1/n) < x。
e
|e(n) - e(n+1)| < x
(1/n!) < x
(1/1) * (1/2) * (1/3) * ... * (1/n) < x
int minN(double x) { double sum = 1; int n; for(n = 0; sum >= x; n++) { sum *= 1/(n+1); } return n; }