用C语言编写程序,求S=1+(1/2!)+(2/3!)+·····+(n/(n+1!)),直到最后一项的绝对值小于10^-5

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/24 06:37:07
用C语言编写程序,求S=1+(1/2!)+(2/3!)+·····+(n/(n+1!)),直到最后一项的绝对值小于10^-5
x){>ek_hxgӶWt?կlcS=FtF`0چ ) y>{ӎ 4C8]S"_fC@93/94%UA$%3_/C ,_hdf^B5ԒĜTDqzLUG[j^U&zpn)j$ˡZ چA$;!! pMԖgdj}SZ%T9,LQM@"`8i(A@ 5RISAՄ_\gJ g

用C语言编写程序,求S=1+(1/2!)+(2/3!)+·····+(n/(n+1!)),直到最后一项的绝对值小于10^-5
用C语言编写程序,求S=1+(1/2!)+(2/3!)+·····+(n/(n+1!)),直到最后一项的绝对值小于10^-5

用C语言编写程序,求S=1+(1/2!)+(2/3!)+·····+(n/(n+1!)),直到最后一项的绝对值小于10^-5
#include "stdio.h"
double calcS(double t)
{
int i = 1;
double retValue = 0;
double sglValue = 1;
double dFenzi = 0;
double dFenmu = 1;
do
{
dFenzi += 1;
dFenmu *= (i+1);
sglValue = dFenzi/dFenmu;
retValue += sglValue;
}while(sglValue > t);
return retValue;
}
void main()
{
printf("calcS(0.00001) = %lf",calcS(0.00001));
}