/*用1+1/1!+1/2!+…+1/n!计算e的近似值*/
#include<stdio.h>
void main(){
int n, i, m;
double sum,h;
printf("enter a number:");
scanf_s("%d", &n);
m = 1; sum = 1;
//if (n < 34&&n>8){
for (i = 1; i <= n; i++){
m = m*i;
h = 1.0 / m;
sum = sum + h;
}
printf("%lf", sum);
//}
//else
// printf("输入的数太大或太小,请重新输入");
getchar();
getchar();
}