Skip to content

Computing Mersenne Primes using Java and BigInteger

Notifications You must be signed in to change notification settings

kdrudy/MersennePrimeJava

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MersennePrimeJava

Computing Mersenne Primes using Java and BigInteger

Mersenne Primes are prime numbers one less than a power of two (2^N - 1).

These numbers get large fast so in order to calculate them with Java you need to use BigInteger, which can hold a whole number as large as the available memory.

Current success with this code running on a Raspberry PI Model A at home:

Number Power Value Time
1 2 3 14ms
2 3 7 2ms
3 5 31 1ms
4 7 127 2ms
5 13 8191 4ms
6 17 131071 16ms
7 19 524287 30ms
8 31 2147483647 597ms
9 61 2305843009213693951 4193375ms

Runtime on my work 2015 Macbook Pro:

Number Power Value Time
1 2 3 0ms
2 3 7 0ms
3 5 31 0ms
4 7 127 0ms
5 13 8191 0ms
6 17 131071 0ms
7 19 524287 0ms
8 31 2147483647 11ms
9 61 2305843009213693951 43063ms

About

Computing Mersenne Primes using Java and BigInteger

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages