C语言编程序,求e的近似值e≈1+1/2!+1/3!+…+1/n!是多少?

如题所述

第1个回答  推荐于2019-09-30
#include <math.h>
main()
{
int n,i,b;
long a=1;
double e,x;
printf("Input n:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
a*=i;
e+=1.0/a;

}
printf("e=%lf",e);
x=e-(int)e;
printf(" input bit b(1~14):");/*这边给您输出最多14位的小数*/
scanf("%d",&b);
printf("is %ld",(int)(x*pow(10,b)));
}

精确小数的 可以加
do
{

}while(x<0.0000000001);/*数字自己定*/
的代码
希望对你有所帮助!本回答被网友采纳

C语言编程序,求e的近似值e≈1+1\/2!+1\/3!+…+1\/n!
(1)计算前n项 源程序如下:include<stdio.h> int main(){ double item=1,sum=1;int n,i;scanf("%d",&n);for(i=1;i<=n;i++){ item*=1.0\/i;sum+=item;} printf("The sum is lf\\n",sum);return 0;} (2)计算各项直到最后一项小于10^(-4)源程序如下:include<stdio.h>...

C语言编程序,求e的近似值e≈1+1\/2!+1\/3!+?+1\/n!是多少?
e);\\x0d\\x0a x=e-(int)e;\\x0d\\x0aprintf(" input bit b(1~14):");\/*这边给您输出最多14位的小数*\/\\x0d\\x0ascanf("%d",&b);\\x0d\\x0aprintf("is %ld",(int)(x*pow(10,

C语言编程序,求e的近似值e≈1+1\/2!+1\/3!+…+1\/n!(1)计算前20项(2)计 ...
printf("1+1!+1\/2!+1\/3!...+1\/n!=%.2f",sum);}

C语言编写,求e的值.e≈1+1\/1!+1\/2!+1\/3!+……+1\/n!
define N 50 int main(int argc, char* argv[]){ double e=1,t=1;int t1;for (t1=2;t1<=N;++t1){ t*=(double)1\/t1;e+=t;} printf("%lf",e);return 0;} \/\/--- 2.\/\/--- include <stdio.h> const

...公式,求自然对数e的近似值 e=1+1\/1!+1\/2!+1\/3!+...
\/\/C语言中,求e=1\/1!+1\/2!+…+1\/n!精确到10ˉ8#include <stdio.h>int main(void){ long n = 0, ns = 1; double x = 0.0f, y=0.0f, e = 1.0f; for(;;) { n++; \/*计算n*\/ ns *= n; \/*计算n!*\/ x = ns; y = 1.0f \/ x; \/*计算1\/n!*\/ ...

编写程序,根据近似公式e≈1+1\/(1!)+1\/(2!)+1\/(3!)+…+1\/(n!)计算e的...
C代码:include<stdio.h> void main(){ double e=1;double jc=1;\/\/求阶乘,并存入jc中 int i=1;while(1\/jc>=1e-6){ e=e+1\/jc;i++;jc=jc*i;} printf("e=%f\\n",e);} 》其他参考答案》》:http:\/\/zhidao.baidu.com\/question\/56549128.html?si=5 还有不懂可以HI我,只要我...

C语言:按泰勒级数公式e = 1 + 1\/1! + 1\/2! +1\/3! + ... + 1\/n!求e...
a[i]=jiecheng(i); sum += (float)1\/a[i]; } printf("e的值为:%.6f\\n",sum); return 0;}int jiecheng(int N){ if(N==0 || N==1) return 1; else return N*jiecheng(N-1);}运行结果如下:...

c语言编程题,求e的近似值,e=1\/1!+1\/2!+1\/3!+...+1\/n!,累加项小于1
正确的公式为:e=1+1\/1!+1\/2!+1\/3!+...+1\/n!代码实现如下:include<stdio.h> int fun(int n){ if(n == 1)return 1;return n*fun(n-1);} int main(){ double sum =1.0 ;int i = 1;while((1.0\/fun(i))>=1e-8){ sum +=(1.0\/fun(i));i++;} printf("%.8...

...公式计算e的值(精度为1e-5):e=1+1\/1!+1\/2!+1\/3!+1\/4!+…+1\/n...
include<stdio.h> int main(){ int a; double b,c,sum=0;a=1;b=1;c=1;while(b >1e-5){ b=1.0\/a; c=c*b; a++; sum+=c;} sum +=1;printf("e=%lf\\n",sum);}

用c语言编程序求e约等于1+1\/1!+1\/2!+1\/3!+……1\/n!当1\/n!小于等于10的...
unsigned long fac; double e=1.0; fac=n; while(fac>1e-5) { e=e+1.0\/fac; ++n; fac=fac*n; } printf("%f\\n",e);}计算 1\/n!不要都 用整数,1\/fac(n) 如果结果小于1将向下取整为0,用1.0\/fac(n)...

相似回答