Задача в С++.P=(1-1/2^2)(1-1/3^2)...(1-1/n^2),n>1.

Ответы

Ответ дал: fjioewgtjiwejigrew
0

#include <iostream>

#include <vector>

#include <cstdlib>

#include <ctime>

#include <algorithm>

using namespace std;

int main() {

float n;

cin >> n;

if (n <= 1) {

 cout << "wrong data";

 return 0;

}

float P = (1-1/2*2)*(1-1/3*3);

for (int i = 3; i <= n; ++i) {

 P *= (1 - 1 / (n * n));

}

cout << P;

}

Вас заинтересует