/* compute zeta(k) */ #include int main(int argc, char **argv) { int i, j, k, q = 0; double t = 0; if (argc < 2) { fprintf(stderr, "usage: zetacalc k [offset] (k an integer >= 2)\n"); return 1; } k = atoi(argv[1]); if (argc > 2) q = atoi(argv[2]); for (i = 1; i < 1000000; ++i) { double r = 1.0; for (j = 0; j < k; ++j) r *= i; r += q; t += 1 / r; } printf("%lf\n", t); return 0; }