/* error4.c 累積誤差 1/n - 1/(n+1) - 1/(n(n+1)) = 0 のはずが ... */ #include #include main() { int n, j, m; float x = 0.0; for(j = 4; j <= 8; j++){ m = (int)pow(10,j); for(n = 1; n <= m; n++) x += (1.0/n - 1.0/(n+1) - 1.0/(n*(n+1))); printf("%9d項目までの和 %9.6f\n",m,x); } }