mersenne | R Documentation |
Determines whether p is a Mersenne number, that is such that 2^p - 1 is prime.
mersenne(p)
p |
prime number, not very large. |
Applies the Lucas-Lehmer test on p
. Because intermediate numbers will
soon get very large, uses ‘gmp’ from the beginning.
Returns TRUE or FALSE, indicating whether p
is a Mersenne number or not.
https://mathworld.wolfram.com/Lucas-LehmerTest.html
mersenne(2) ## Not run: P <- Primes(32) M <- c() for (p in P) if (mersenne(p)) M <- c(M, p) # Next Mersenne numpers with primes are 521 and 607 (below 1200) M # 2 3 5 7 13 17 19 31 61 89 107 gmp::as.bigz(2)^M - 1 # 3 7 31 127 8191 131071 ... ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.