#include <cmath>
#include <iostream>
using namespace std;
double power(const double x, const unsigned n) {
if (!n) return 1.0;
auto result = x;
for (auto i = 1U; i < n; ++i) result *= x;
return result;
}
double fact(const unsigned n) {
auto result = 1.0;
if (n < 2U) return result;
for (auto i = 2U; i <= n; ++i) result *= i;
return result;
}
double member(double t, double x, unsigned n) {
static const auto b = log(t);
if (!n) return 1.0;
const auto a = power(x, n) * power(b, n);
return a / fact(n);
}
double input(const char* prompt) {
cout << prompt;
double value;
cin >> value;
cin.ignore(0x1000, '\n');
return value;
}
int main() {
cout.setf(ios::fixed);
cout.precision(15);
constexpr auto t = 3.0;
const auto x = input("x: ");
const auto e = input("E: ");
auto n = 0U;
auto m = member(t, x, n);
auto sum = 0.0;
while (e < fabs(m)) {
sum += m;
++n;
m = member(t, x, n);
}
cout << "sum: " << sum << '\n';
cout << "control: " << pow(t, x) << '\n';
}