Mersenne Prime Oracle
Do not use double arithmetics when integer arithmetics can solve the problem as well. The function isPowerOfTwoMinus1 can be written simply as ((x + 1) &amp; x) == 0.

Don't call isMersennePrime twice, just break from the loop.