> i = i++; is supposed to be how the number N is factored.
You want to increment i ; just do
++i ;
- NOT
i = i++ ;
> If the inlining is wrong or useless then should it be moved or removed?
It's not the inline that is wrong; the function would be equally wrong without the inline. Just remove the whole function from your program.
The standard C++ library has overloads of the pow() function in <cmath> as given here:
http://en.cppreference.com/w/cpp/numeric/math/pow
So if you are not using C++11, write
1 2 3
|
template< typename T, typename U >
inline std::uint64_t my_pow( T a, U b )
{ return std::pow( (double)a, (double)b ) + 0.5 ; }
|
and then replace all calls to
pow()
with
my_pow()
If
N happens to be a very large prime number (let us say a 13 digit prime number with 9 as the first digit), this loop is going to take a huge amount of time:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
N = ((k*(pow((long double)2,(long double)j))-1));
do
{
// quotient = N/i; // unnecessary, quotient is computed later.
//i = i++; // undefined; replace with ++i
++i ;
}
while ((N%i) != 0);
quotient = N/i;
|
Assuming that the hardware can do one billion 64-bit integer divisions per second, it will take about three hours.
You need to speed it up by exiting the loop once
i is greater than the square root of
N. Better, limit the divisions to prime numbers up to the square root of
N. (Using a suitable sieve algorithm, pre-generate all prime numbers up to the square root of the largest value of
N that you intend to handle).