Friday, October 6, 2023

π²/6

#include <math.h>
#include <iostream>
#include <cmath>
using namespace std;
double p01 (int N)
{
double s = 0 ;
for (int i = 1; i <= N; i++) s = s + 1./(i*i);
return (s);
}
int main ()
{
int n;
cout << "N=";
cin >> n;
cout << " s=" << p01(n) << "\nπ²/6=" << M_PI*M_PI/6. << endl;
}

No comments:

Post a Comment

N-point Star in Microsoft Visual Studio Console App

#include <windows.h> #include <cmath> #include <iostream> LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,...