...

/

This Should Ring a Bell

This Should Ring a Bell

Test your C programming skills by solving the given puzzle about series summation.

We'll cover the following...

Puzzle code

...
Press + to interact
#include <stdio.h>
int main()
{
const int limit = 1000;
int x;
float t;
/* divergent */
t = 0.0;
for(x=1; x<=limit; x++ ) t += 1.0 / (float)x;
printf("Divergent: %.4f\n", t);
/* convergent */
t = 0.0;
for(x=1; x<=limit; x*=2 ) t += 1.0 / (float)x;
printf("Convergent: %.4f\n", t);
return(0);
}
...