#include<stdio.h> float GetSum(int n); int main(void){ int n; scanf("%d",&n); if(n>0){ printf("s=%f",GetSum(n)); }else{ printf("error"); } } float GetSum(int n){ float s = 1,t; int i,j; for(i=1;i<=n;i++){ t=1; for(j=1;j<=i;j++){ t*=j; } s+=1/t; } return s; }
时间: 2024-10-07 04:55:45