main()
{
int i,j,k;
float sum=0;
clrscr();
scanf("%d",&n);
if(n>=3&&n<=20)
{
for(i=1;i<=n;i++)
{k=1;
for(j=1;j<=i;j++)
k=k*j;
sum=sum+1.0/k;
}
printf("%d",sum);
}
else
printf("wrong");
}
#include
void main()
{
int i,n;
double sum=0,p=1;
printf("Please Input n:");
scanf("%d",&n);
if(n>=3&&n<=20)
{
for(i=1;i<=n;i++)
{
p=p*i;
sum=1/p+sum;
}
printf("sum=%f\n",sum);
}
else
printf("20≥n≥3 needed\n");
}