From what I glance at your code, are you sure that an int can handle 20 digit numbers? That may be the first problem you need to solve -- data type -- before you attempt to find a number...
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17
NathanOliver
Posting Virtuoso
1,515 posts since Apr 2009
Reputation Points: 281
Solved Threads: 277
Skill Endorsements: 3
There are a lot of those primes out there, but generating them will undoubtedly be slow... especially if you want the really big ones. I would suggest A) looking into an arbitrary arithmetic library (so that you can handle epicly large numbers) then B) google for lists of large numbers, there are tons of them. You could then store them in an array and randomly pick one from it. Another option is to store an array of ints representing valid exponents for Mersenne Primes, then just generate the corresponding prime.
Labdabeta
Practically a Master Poster
613 posts since Feb 2011
Reputation Points: 27
Solved Threads: 31
Skill Endorsements: 1
And Labdabeta, what do you mean by arbitrary arithmetic library ?
Bad choice of words. He means a large-number arithmetic library? Arbitrary is not correct. You want to pick a package with care.
WaltP
Posting Sage w/ dash of thyme
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 37
pyTony
pyMod
6,301 posts since Apr 2010
Reputation Points: 879
Solved Threads: 986
Skill Endorsements: 26
Question Answered as of 9 Months Ago by
WaltP,
NathanOliver,
Taywin
and 3 others