Hello I,ve written this program that can calculate any Mersenne number.
The problem is that when I run it and tell it to calculate M6972593 it takes way too long (about five days!) what can I do to improve the speed of this program?
The first thing I notice is that you call pow(10,18) over and over again.
Every time you call the std::pow() function, time is wasted recalculating 10 to the power of 18.
So why not just store the result into a constant, then use the constant instead of the function call:
constdouble ten_pow = pow(10, 18);
Also be sure to turn on Optimizations in your compiler settings.
If using GCC, compile with the -O3 flag.
If using Visual Studio, compile in Release mode.
Unfortunately I can't help you more, because I don't know how to improve the algorithm itself.