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. php+mysql将大数据sql文件导入数据库

    <?php $file_name = "d:test.sql"; $dbhost = "localhost"; $dbuser = "root& ...

  2. node.js + socket.io实现聊天室一

    前段时间,公司打算在社区做一个聊天室.决定让我来做.本小白第一次做聊天类功能,当时还想着通过ajax请求来实现.经过经理提示,说试试当前流行的node.js 和socket.io来做.于是就上网学习研 ...

  3. php代码-1

  4. NAS4Free 安装配置(二)系统安装

    NAS4Free系统安装 看一看BIOS设置 开机按DEL进BIOS 改日期时间 这里可以设置RAID,因为ZFS的RAID功能更好,所以我们在这里不配置RAID 制作LiveUSB 用软件(USB ...

  5. linux下snprintf和sprinf很少被提及的区别

    函数原型:int snprintf(char *dest, size_t size, const char *fmt, ...);函数说明: snprintf函数中的第二个参数,size的解释:siz ...

  6. [Codeforces Round #186 (Div. 2)] B. Ilya and Queries

    B. Ilya and Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. php平台移植windows和linux

    2015/1/14 今天项目中遇到一个问题,在本地运行没有问题,挂到服务器上,就运行错误.过程中比较粗心,知道导致这样的原因,居然小时漏掉了一些细节. 比如,在php中通过声明__autoload() ...

  8. WPF笔记(2.9和2.10)——Layout

    原文:WPF笔记(2.9和2.10)--Layout 2.9讲的是,如果内部设定超过容器大小,怎么办?StackPanel会裁剪越界部分DockPanel和Grid会智能判断,从而决定换行. 2.10 ...

  9. 一篇非常经典的springMVC注解实现方式详解

    今天公司让搭建个springMVC的注解框架,研究了好半天,网络搜罗了半天,好不容易找到篇,拿来分享下: 原文出处:http://itxxz.com/a/kuangjia/2014/0531/4.ht ...

  10. mongodb----pymongo的用法

    pymongo是python的一个模块,可能通过sudo pip install pymongo来安装. 导入pymongo import pymongo 创建连接 conn = pymongo.Co ...