UNI_Python/ext_02/test.cpp

19 lines
565 B
C++
Raw Normal View History

2024-03-01 12:32:09 +01:00
#include <iostream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/math/special_functions/factorials.hpp>
namespace mp = boost::multiprecision;
mp::cpp_dec_float_1000 calc(const mp::cpp_dec_float_1000& const_value) {
mp::cpp_dec_float_1000 sum = 0;
for (int k = 1; k <= 10000; ++k) {
sum += pow(const_value, k) / boost::math::factorial<mp::cpp_dec_float_1000>(k);
}
return sum;
}
int main() {
mp::cpp_dec_float_1000 result = calc(log(mp::cpp_dec_float_1000(2));
std::cout << result << std::endl;
return 0;
}