当前位置:网站首页>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
边栏推荐
- The use of word in graduation thesis
- 机动目标跟踪——当前统计模型(CS模型)扩展卡尔曼滤波/无迹卡尔曼滤波 matlab实现
- 2022 mechanical fitter (primary) examination summary and mechanical fitter (primary) reexamination examination
- Properties of 15MnNiNbDR low temperature vessel steel, Wugang 15MnNiDR and 15MnNiNbDR steel plates
- Huawei machine test questions column subscription Guide
- Nacos - 服务发现
- Field agricultural irrigation system
- There are many problems in sewage treatment, and the automatic control system of pump station is solved in this way
- Matlab tips (23) matrix analysis -- simulated annealing
- [no title] free test questions for constructor municipal direction general foundation (constructor) and theoretical test for constructor municipal direction general foundation (constructor) in 2022
猜你喜欢

Share 7 books I read in the first half of 2022
![Matlab [functions and images]](/img/8a/d2f68b5a7ed396ad20234c0aa24953.jpg)
Matlab [functions and images]

機動目標跟踪——當前統計模型(CS模型)擴展卡爾曼濾波/無迹卡爾曼濾波 matlab實現

Mavros sends a custom topic message to Px4

毕业论文中word的使用1-代码域标公式

嵌入式工程师面试题3-硬件

Gateway-88

截图小妙招

Vscode customize the color of each area

What is the material of 16mo3 steel plate? What is the difference between 16mo3 and Q345R?
随机推荐
Screenshot tips
[no title] free test questions for constructor municipal direction general foundation (constructor) and theoretical test for constructor municipal direction general foundation (constructor) in 2022
[deep analysis of C language] - data storage in memory
你了解数据是如何存储的吗?(C整型和浮点型两类)
Advanced level of C language pointer (Part 1)
Mavros sends a custom topic message to Px4
Principle and application of single chip microcomputer - off chip development
factory type_id::create过程解析
What is the material of 16MnDR, the minimum service temperature of 16MnDR, and the chemical composition of 16MnDR
Matlab [function derivation]
基础:2.图像的本质
Brief introduction to AES
R语言观察日志(part24)--初始化设置
公网集群对讲+GPS可视追踪|助力物流行业智能化管理调度
MD文档中插入数学公式,Typora中插入数学公式
Only in China! Alicloud container service enters the Forrester leader quadrant
Burpsuite -- brute force cracking of intruder
Intelligent water supply system solution
基础:3.opencv快速入门图像和视频
ARM v7的体系结构A、R、M区别,分别应用在什么领域?