当前位置:网站首页>Programming with C language: calculate with formula: e ≈ 1+1/1+ 1/2! …+ 1/n!, Accuracy is 10-6
Programming with C language: calculate with formula: e ≈ 1+1/1+ 1/2! …+ 1/n!, Accuracy is 10-6
2022-07-01 08:41:00 【Writing poetry by programming】
On the first code :
#include<stdio.h>
void main()
{
float f(float x);// Function declaration
double b=1;
float j;
for(j=1;(1.0/f(j))>1.0e-6;j++)
{
b=b+1.0/f(j);
}
printf("%f\n",b);
}
float f(float x)
{
float i;
float y=1;
for(i=1;i<=x;i++)
y*=i;
return y;
}
This problem uses a factorial function , Call him in the main function and guarantee the last item >10-6 To the power of
边栏推荐
猜你喜欢

Centos7 shell脚本一键安装jdk、mongo、kafka、ftp、postgresql、postgis、pgrouting
![Matlab [function derivation]](/img/ba/9fb9da8a458d0c74b29b21a17328fc.png)
Matlab [function derivation]

动态代理

Advanced C language pointer (Part 2)

15Mo3 German standard steel plate 15Mo3 chemical composition 15Mo3 mechanical property analysis of Wuyang Steel Works

There are many problems in sewage treatment, and the automatic control system of pump station is solved in this way

19Mn6 German standard pressure vessel steel plate 19Mn6 Wugang fixed binding 19Mn6 chemical composition

Intelligent water supply system solution

VSYNC+三重缓存机制+Choreographer

Maneuvering target tracking -- current statistical model (CS model) extended Kalman filter / unscented Kalman filter matlab implementation
随机推荐
The use of word in graduation thesis
win7 pyinstaller打包exe 后报错 DLL load failed while importing _socket:参数错误
Matlab tips (23) matrix analysis -- simulated annealing
R语言入门
DID的使用指南,原理
中考体育项目满分标准(深圳、安徽、湖北)
避免按钮重复点击的小工具bimianchongfu.queren()
Audio audiorecord create (I)
电脑小技巧
SPL installation and basic use (II)
15Mo3 German standard steel plate 15Mo3 chemical composition 15Mo3 mechanical property analysis of Wuyang Steel Works
Nacos - 服务发现
VSYNC+三重缓存机制+Choreographer
Model and view of QT
Matlab [functions and images]
基础:3.opencv快速入门图像和视频
3、Modbus通讯协议详解
【js逆向】md5加密参数破解
Matlab tips (16) consistency verification of matrix eigenvector eigenvalue solution -- analytic hierarchy process
Tita OKR: a dashboard to master the big picture