#include <iostream>
#include <cmath>
using namespace std;
double arr(double sum, double a, double E, int i)
{
if (fabs(a *= (double)(i + 1) * pow(3 * i, -1)) < E)
{
return sum;
}
else
{
i++;
sum += a;
return arr(sum, a, E, i);
}
}
int main()
{
int i=1;
double E; // переменная для обозначения точности
double a = 1 / 3.0, sum = 1 / 3.0;
//присваиваем переменным a(член ряда) и sum значение первого члена ряда
cin >> E;
cout << arr(sum, a, E, i) << endl;
system("pause");
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+IAp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKZG91YmxlIGFycihkb3VibGUgc3VtLCBkb3VibGUgYSwgZG91YmxlIEUsIGludCBpKQp7CglpZiAoZmFicyhhICo9IChkb3VibGUpKGkgKyAxKSAqIHBvdygzICogaSwgLTEpKSA8IEUpCgl7CgkJcmV0dXJuIHN1bTsKCX0KCWVsc2UKCXsKCQlpKys7CgkJc3VtICs9IGE7CgkJcmV0dXJuIGFycihzdW0sIGEsIEUsIGkpOwoJfQp9CmludCBtYWluKCkKewoJaW50IGk9MTsKCWRvdWJsZSBFOyAvLyDQv9C10YDQtdC80LXQvdC90LDRjyDQtNC70Y8g0L7QsdC+0LfQvdCw0YfQtdC90LjRjyDRgtC+0YfQvdC+0YHRgtC4Cglkb3VibGUgYSA9IDEgLyAzLjAsIHN1bSA9IDEgLyAzLjA7CgkvL9C/0YDQuNGB0LLQsNC40LLQsNC10Lwg0L/QtdGA0LXQvNC10L3QvdGL0LwgYSjRh9C70LXQvSDRgNGP0LTQsCkg0Lggc3VtINC30L3QsNGH0LXQvdC40LUg0L/QtdGA0LLQvtCz0L4g0YfQu9C10L3QsCDRgNGP0LTQsAoJY2luID4+IEU7Cgljb3V0IDw8IGFycihzdW0sIGEsIEUsIGkpIDw8IGVuZGw7CglzeXN0ZW0oInBhdXNlIik7CglyZXR1cm4gMDsKfQo=