The first known prime found to exceed one million digits was discovered in 1999, and is a Mersenne prime of the form 2^6972593−1; it contains exactly 2,098,960 digits. Subsequently other Mersenne primes, of the form 2^p−1, have been found which contain more digits.
However, in 2004 there was found a massive non-Mersenne prime which contains 2,357,207 digits: 28433�2^7830457+1.
Find the last ten digits of this prime number.
I tried using BigInteger to compute the prime it self, I think it would take years to compute it, so I need another way around it. Can anyone suggest any method? thanks
I changed your code to loop 5 times, and print out n each time. i get this: java -cp . Problem97 n is 2 n.pow is 1 n is 4 n.pow is 2 n is 16 n.pow is 3 n is 256 n.pow is 4 n is 65536 n.pow is 5 n is 4294967296 n.pow is 6 n is 13709551614 n.pow is 7 n is 13709551614 n.pow is 8 9223372036854775807
What you are doing here each time is raising N to the power of 2. So, first you take 2, and raise it to the power of 2, giving 4.
you then take 4, and raise IT to the power of 2, giving you 16. you then raise 16 to the power of 2, giving 256, etc.
you don't want to raise it by the power of 2 each iteration through the loop... you want to MULTIPLY it by 2 each time through the loop.
Also, there is a much simpler way to chop of extra digits, using a basic operator. do you know what 'modulus' means? It basically means "give me the remainder after i divide". so, '23 mod 5' would be 3. '15 mod 7' would be 1.
so, '217 mod 100' is 17. there is an operator that will do this for you. [ May 16, 2008: Message edited by: fred rosenberger ]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com