标签:log == this form val value actual put div
A simple mathematical formula for e is
where n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n.
1 #include<stdio.h> 2 int jc(int n) 3 { 4 int i=1,s=1; 5 if(n==1||n==0) 6 return 1; 7 while(i<=n) 8 { 9 s*=i; 10 i++; 11 } 12 return s; 13 } 14 int main() 15 { 16 double a[10]; 17 a[0]=1; 18 for(int i=1;i<=9;i++) 19 { 20 a[i]=1.0/jc(i)+a[i-1]; 21 } 22 printf("n e\n"); 23 printf("- -----------\n"); 24 for(int i=0;i<=9;i++) 25 { 26 if(i!=8) 27 printf("%d %.10g\n",i,a[i]); 28 else 29 printf("%d %.9f\n",i,a[i]); 30 } 31 return 0; 32 }
标签:log == this form val value actual put div
原文地址:http://www.cnblogs.com/97-ly/p/6820660.html