当前位置:网站首页>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
边栏推荐
- Principle and application of single chip microcomputer - off chip development
- [untitled]
- Huawei machine test questions column subscription Guide
- I would like to know the process of stock registration and account opening by mobile phone? In addition, is it safe to open a mobile account?
- Audio-AudioRecord create(一)
- 电视机尺寸与观看距离
- MAVROS发送自定义话题消息给PX4
- Matlab tips (23) matrix analysis -- simulated annealing
- Gateway-88
- 截图小妙招
猜你喜欢
随机推荐
避免按钮重复点击的小工具bimianchongfu.queren()
《微机原理》-绪论
中断与其他函数共享变量、临界资源的保护
Yolov5 advanced 7 target tracking latest environment setup
Guidelines and principles of did
Centos7 shell脚本一键安装jdk、mongo、kafka、ftp、postgresql、postgis、pgrouting
2022 ordinary scaffolder (special type of construction work) examination question bank and the latest analysis of ordinary scaffolder (special type of construction work)
Advanced API
SPL installation and basic use (II)
Pipeline detection of UAV Based on gazebo
性能提升2-3倍!百度智能云第二代昆仑芯服务器上线
R语言入门
Leetcode t31: prochain arrangement
C语言学生信息管理系统
Properties of 15MnNiNbDR low temperature vessel steel, Wugang 15MnNiDR and 15MnNiNbDR steel plates
Insert mathematical formula in MD document and mathematical formula in typora
The era of low threshold programmers is gone forever behind the sharp increase in the number of school recruitment for Internet companies
Leetcode t29: divide two numbers
《单片机原理与应用》——并行IO口原理
There are many problems in sewage treatment, and the automatic control system of pump station is solved in this way