Re: Seeking for better algo

I was about to suggest something crude that abuses the 2^n bitshift relationship of 1 << n:

and warn you it will take a long time to compute no matter how you optimize it. Then I read this:

Quote:

... get the last 10 digits of that value

Take a look at the modPow() function of BigInteger and consider how it can be used to take the modulo and compute the power together instead of doing them separately.

Re: Seeking for better algo

Quote:

**CampwideGames wrote**

Start with 2, 4, 8, 16, and so on, then when your number gets above ten digits just subtract off 10000000000, then double what you have left. The remaining ten digit number will be equal to the last ten digits of your final number. Program-wise you should be able to do it in a minute, no sweat.

thank you sir :) it worked. but i did not check if the number exceeds 10 digits, i just mod it to 1000000000 everytime i double it, because i think checking the number using if-else statement will cost time. it execute less than a SECOND now, thank you for your help.