#include
using namespace std;
int main(){
int n;
double p=1;
cout << "n = ", cin >> n, cout << "\n";<br> for(int i=1; i <= n; i++){<br> if (i % 2 == 1) p = p*(double(i+1))/i;
else p = p*(double(i))/(i+1);
}
cout << "p = " << p << "\n";<br> return 0;
}
Пример:
n = 5
p = 1.70667