#include
int main()
{
int x, i, n;
double y;
printf("Input a integer: ");
scanf("%d", &x);
n = 1;
y = 0.0;
for (i = 1; i <= x; i++)
{
n *= i;
y += 1.0 / (double)n;
}
printf("The result is: %10.4lf\n", y);
}
#include
void main()
{
int i,n,j;
double s1,s2;
s2=0;
printf("请输入一个n值");
scanf("%d",&n);
for(j=1;j<=n;j++)
{
s1=1;
for(i=1;i<=j;i++)
s1=s1*i;
s2=1.0/s1+s2;
}
printf("%f",s2);
}
#include
main()
{
float e;
int i,a,n;
scanf("%d",&n);
for(i=1,a=1,e=1;i<=n;)
{a*=i; e+=1.0/a;i++;}
printf("%.4f",e);
}