fork download
  1. #include <stdio.h>
  2.  
  3. #define F float
  4. #define c(x,n) 1+g(1,n,x,1,1,1)
  5. F g(F i,F n,F x,F s,F p,F f){s=-s;p*=x*x;f*=i;return i<n?g(i+1,n,x,s,p,f)+s/2*p/f:0;}
  6.  
  7. int main(void)
  8. {
  9. printf("%f", c(0.5,2));
  10. return 0;
  11. }
  12.  
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
0.875000