Skip to content
Snippets Groups Projects
Select Git revision
  • e5a55ae5d895b36506b339f1f24833424616305f
  • master default protected
  • 2018ws
  • 2017ws
  • 2016ws
5 results

sum-02.c

Blame
  • Forked from Peter Gerwinski / hp
    48 commits behind the upstream repository.
    sum-02.c 275 B
    #include <stdio.h>
    #include <math.h>
    
    /* 1/1² + 1/2² + 1/3² + ... = pi²/6 */
    
    int main (void)
    {
      float pi = M_PI;
      printf ("%0.9f\n", pi * pi / 6.0);
      float S = 0.0;
      for (float x = 1; x <= 1000000; x++)
        S += 1.0 / (x * x);
      printf ("%0.9f\n", S);
      return 0;
    }