Description

A simple mathematical formula for e is

where n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n.        
 

Output

Output the approximations of e generated by the above formula for the values of n from 0 to 9. The beginning of your output should appear similar to that shown below.        
 

Sample Output

n e - -----------
0 1
1 2
2 2.5
3 2.666666667
4 2.708333333
 
 
 
#include<iostream>
#include<iomanip>
using namespace std;
double f(int n)
{
long double a=;
for(int i=;i<=n;i++)a*=i;
return a;
}
int main()
{
cout << "n e"<<endl<<"- -----------"<<endl;
double e=;
cout<<<<" "<<e<<endl;
for(int i=;i<=;++i)
{
e+=/f(i);
cout<<i<<" ";
if(i!=) cout<<setprecision()<<e<<endl;
else cout<<setprecision()<<e<<<<endl;
}
//system("pause");
return ;
}

不难!!不要忘了long double !!!!

I - u Calculate e的更多相关文章

  1. [转] PHP计算两个坐标之间的距离, Calculate the Distance Between Two Points in PHP

    Calculate the Distance Between Two Points in PHP There are a lot of applications where it is useful ...

  2. CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved

    CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin ...

  3. maven -- 问题解决(二)解决“Could not calculate build plan”问题

    错误提示如下:(eclipse+maven) Could not calculate build plan: Failure to transfer org.apache.maven.plugins: ...

  4. 线段树 + 矩阵 --- ZOJ 3772 Calculate the Function

    Calculate the Function Problem's Link:   http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCod ...

  5. hdu 1012:u Calculate e(数学题,水题)

    u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  6. Calculate its MTBF assuming 2000 FITS for each DRAM

    COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION A common unit of meas ...

  7. u Calculate e 分类: HDU 2015-06-19 22:18 14人阅读 评论(0) 收藏

    u Calculate e Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...

  8. How to calculate a good InnoDB log file size

    Peter wrote a post a while ago about choosing a good InnoDB log file size.  Not to pick on Peter, b ...

  9. Calculate the formula

    Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+……+ n ^2.   Input ...

  10. How to Calculate difference between two dates in C# z

    Do you need to find the difference in number of days, hours or even minute between the two date rang ...

随机推荐

  1. zeromq源码分析笔记之无锁队列ypipe_t(3)

    在上一篇中说到了mailbox_t的底层实际上使用了管道ypipe_t来存储命令.而ypipe_t实质上是一个无锁队列,其底层使用了yqueue_t队列,ypipe_t是对yueue_t的再包装,所以 ...

  2. Mysql int(11) 和 int(1)

    Mysql 可以为整数类型制定宽度,例如:int(11) ,对大多数应用这是没有意义的:它不会限制值的合法范围,它只是规定了Mysql的一些交互工具(例如mysql命令行客户端)用来显示字符个数.对于 ...

  3. React/React Native的 ES5 ES6 写法对照

      ES5 ES6 模块 var React = require("react-native); var { Image, Text, View } = React;   import Re ...

  4. Oracle遇到的一些问题

    1.制造数据时出现错误 ORA-30009问题 计划任务: insert into test select rownum,sysdate from dual connect 会出现ORA-30009 ...

  5. 微信分享jssdk config:invalid signature 签名错误

    使用微信分享时,按照官方给的demo,使用时一直提示签名错误. 根据微信开发文档(http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd ...

  6. Unicode的解救方案 - Windows程序设计(SDK)002

    Unicode的解救方案 让编程改变世界 Change the world by program 内容节选: 早期的Windows也是使用ASCII字符集,ASCII好处多多,但ASCII的第一个字母 ...

  7. 如何实现SQL事务的提交,又不对外进行污染

    一.以下是本人的一点思路: 1.在事务方法中,参数运用委托Func,选用Func 的原因是多入参,单一出参2.事务传参运用泛型,选用泛型的原因是可以减少代码量,类型安全 二.说明中涉及4个类:1.Or ...

  8. 在开启bin-log日志下Mysql报错

    This function has none of DETERMINISTIC, NO SQL解决办法 创建存储过程时 出错信息: ERROR 1418 (HY000): This function ...

  9. VCMI Mods list

    http://heroescommunity.com/viewthread.php3?TID=40902 http://heroes3wog.net/ http://heroes3towns.com/ ...

  10. 需要考虑的9个SEO实践

    搜索引擎优化重要吗?我们知道,网站设计是把屏幕上平淡无奇变成令人愉快的美感,更直观地辨认信息.这也是人与人之间在沟通想法,这样的方式一直在演变. 穴居人拥有洞穴壁画,古埃及人有象形文字,现代人有网页设 ...