//计算 1+1/2!+1/3!+1/4!+...1/20!=?
double i ;
double s=0;
double a=1;
for(i=1;i<=20;i++)
{
a=a*i;
s=s+1/a;
}
System.out.println(s);
时间: 2024-10-29 03:08:48
//计算 1+1/2!+1/3!+1/4!+...1/20!=?
double i ;
double s=0;
double a=1;
for(i=1;i<=20;i++)
{
a=a*i;
s=s+1/a;
}
System.out.println(s);