计算 1+1/2!+1/3!+1/4!+...1/20!=?

 

package liu0912;

public class Jiecheng2 {

public static void main(String[] args) {
double sum=0;double i=1;double j=1;
for(i=1;i<=20;i++)
{

double sum=0;
for(j=1;j<=i;j++)
{
sum2=sum2*j;
}
sum=sum+(1/sum2);
}
System.out.println("20的阶乘是:"+sum);

}

}

posted @ 2016-09-12 20:50  琢磨先生  阅读(4362)  评论(0编辑  收藏  举报
AmazingCounters.com