当前位置:网站首页>7-15 calculation of PI
7-15 calculation of PI
2022-07-03 14:14:00 【Big fish】
According to the following relation , Find the value of pi , Until the value of the last item is less than the given threshold .

Input format :
The input gives less than... On one line 1 The threshold of .
Output format :
Output the approximate PI satisfying the threshold condition in one line , Output after decimal point 6 position .
sample input :
0.01
sample output :
3.132157Code thinking :
#include <stdio.h>
int main()
{
double PI=1;
double t;
double num=1.0;
int i=1;
scanf("%lf",&t);
while(num>t) // Stop until the last item is less than the threshold
{
num=num*i/(i*2+1); // The numerator in each fraction is a factorial , The denominator is an arithmetic sequence
PI+=num;
i++;
}
printf("%.6f\n",PI*2);
return 0;
}边栏推荐
- Leetcode(4)——尋找兩個正序數組的中比特數
- 天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
- JS get DPI, PX to cm, cm to PX
- 金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子
- 【吉林大学】考研初试复试资料分享
- Canvas utility library fabric JS user manual
- Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email
- Exercise 10-6 recursively find Fabonacci sequence
- “又土又穷”的草根高校,凭什么被称为“东北小清华”?
- JS new challenges
猜你喜欢

Exercise 10-1 calculate the sum of 1 to n using recursive functions

常见问题之PHP——ldap_add(): Add: Undefined attribute type in

JS Part 2

QT learning 19 standard dialog box in QT (top)

Metal organic framework (MOFs) antitumor drug carrier | pcn-223 loaded with metronidazole | uio-66 loaded with ciprofloxacin hydrochloride(

泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东

Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值

Jiuyi cloud black free encryption free version source code
![[clean up the extraordinary image of Disk C]](/img/0d/331115bc5d82d6337ae975a08494b2.jpg)
[clean up the extraordinary image of Disk C]

Exercise 10-6 recursively find Fabonacci sequence
随机推荐
Redis: redis data structure and key operation commands
Exercise 10-8 recursive implementation of sequential output of integers
1px problem of mobile terminal
Leetcode (4) - - trouver la médiane de deux tableaux ordonnés positifs
How to bold text in AI
Canvas utility library fabric JS user manual
GRPC的四种数据流以及案例
中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿
JS get DPI, PX to cm, cm to PX
C library function - qsort()
JS first summary
战略、战术(和 OKR)
Back to top implementation
Message subscription and publishing
js 2023. String pair equal to the target string after connection
金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
Article content typesetting and code highlighting
JVM垃圾回收机
Exercise 10-6 recursively find Fabonacci sequence
QT learning 24 layout manager (III)