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. QT5-控件-QDateEdit 和 日期类QDate

    #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QDate> #inclu ...

  2. vc2015编译protobuf

    下载地址:https://github.com/google/protobuf 1.编译通过cmake生成sln文件来编译用cmd命令 cd 到3.0.0-beta-4\cmake mkdir bui ...

  3. attachEvent和addEventListener

    attachEvent和addEventListener在前端开发过程中经常性的使用,他们都可以用来绑定脚本事件,取代在html中写obj.onclick=method. 相同点: 它们都是dom对象 ...

  4. Ubuntu 修改 Apache2 用户组 方法

    检查/etc/apache2/envvars文件,发现其中需要使用/etc/apache2/envvars文件中的以下几个环境变量 export APACHE_RUN_USER=www-data ex ...

  5. 求实现sql?

    id name pid1 曾祖父 02 祖父 13 父亲 24 儿子 35 孙子 4备注:用一条数据库语句来解决查询结果:name1 name2 name3曾祖父 祖父 父亲曾祖父 父亲 儿子曾祖父 ...

  6. cocos2d-js 入门一 ([isNaN()和isFinite(),字符和Number之间的转化)

    isNaN() : 用于检查其参数是否是非数字值.// 提示:是非数字哦.(not a number)document.write(isNaN(0) )  //返回falsedocument.writ ...

  7. [TYVJ] P1423 GF和猫咪的玩具

    GF和猫咪的玩具 描述 Description GF同学和猫咪得到了一个特别的玩具,这个玩具由n个金属环(编号为1---n),和m条绳索组成,每条绳索连接两个不同的金属环,并且长度相同.GF左手拿起金 ...

  8. 去掉Eclipse打开后定期弹出Usage Data Upload对话框

    Eclipse 的 UDC 老定期蹦出来说要上传使用数据到 eclipse 官网服务器去除方法: 1.删除 eclipse/plugins 目录下以 org.eclipse.epp.usagedata ...

  9. PHP中$_GET['name']与$_POST['name']变量直接用变量名$name的php配置

    php中,可以直接使用参数名称作为变量来接收get或post的传参,条件是php.ini中register_global设置成On 另外一种方法: if(!ini_get('register_glob ...

  10. Powershell环境变量

    Powershell环境变量 9 12月, 2011  在 Powershell tagged 变量by Mooser Lee 本文索引 [隐藏] 1读取特殊的环境变量 2查找环境变量 3创建新的环境 ...