http://acm.hdu.edu.cn/showproblem.php?pid=1012
简单套公式
# include <stdio.h> double Factorial(double num) { if(num == 0 || num == 1) return 1; return Factorial(num - 1) * num; } int main () { double Ans[11]; int i; printf("n e\n- -----------\n0 1\n1 2\n2 2.5\n"); Ans[2] = 2.5; for(i = 3; i <= 9; i++) { Ans[i] = Ans[i - 1] + (1 / Factorial(i)); printf("%d %.9lf\n",i, Ans[i]); } return 0; }
时间: 2024-10-06 11:43:13