![]() |
![]() |
#1 |
Sep 2002
Database er0rr
118F16 Posts |
![]()
Not as efficient as LL:
Code:
yaMersennePRP(p)=local(n=2^p-1,a=Mod(4,n),b=a+1);for(k=2,p,a=2*a*b;b=a+1);print(p" "a==4) ![]() |
![]() |
![]() |
![]() |
#2 | |
"Forget I exist"
Jul 2009
Dartmouth NS
2·3·23·61 Posts |
![]() Quote:
1) getting rid of b is easy as at every step using it you are calculating 2*a^2+2*a I had a few more at first but I tested them and they didn't work to replicate, they went down the wrong division of everything by 2 path I think. |
|
![]() |
![]() |
![]() |
#3 |
"Rashid Naimi"
Oct 2015
Remote to Here/There
44458 Posts |
![]()
Isn't LL a primality test rather than a PRP test?
Is this algo also a deterministic primality test? |
![]() |
![]() |
![]() |
#4 |
Sep 2002
Database er0rr
118F16 Posts |
![]() |
![]() |
![]() |
![]() |
#5 |
"Rashid Naimi"
Oct 2015
Remote to Here/There
92516 Posts |
![]()
So I assume you know of values for p which return true but are in fact yield composite Mersennes. Correct?
Last fiddled with by a1call on 2017-01-21 at 00:48 |
![]() |
![]() |
![]() |
#6 |
Sep 2002
Database er0rr
5×29×31 Posts |
![]() |
![]() |
![]() |
![]() |
#7 |
"Rashid Naimi"
Oct 2015
Remote to Here/There
2,341 Posts |
![]()
Well, that makes it more interesting than just another PRP test.
![]() Are there any values that you know of, that yield false but are in fact prime? That shouldn't be too difficult to check given the limited number of known MPs. |
![]() |
![]() |
![]() |
#8 | |
Aug 2006
10111011000112 Posts |
![]() Quote:
Code:
#include <pari/pari.h> /* For use in gp: GP;install("testMersenne","lU","testMersenne","./filename.gp.so"); */ long testMersenne(ulong p) { if (p < 4) return p > 1; pari_sp av = avma; GEN n = subiu(int2u(p), 1); pari_sp btop = avma; GEN a = utoipos(4); ulong k; long ret; for (k = 2; k <= p; ++k) { a = remii(shifti(addii(sqri(a), a), 1), n); if (gc_needed(btop, 1)) a = gerepileuptoint(btop, a); } ret = absequaliu(a, 4); avma = av; return ret; } |
|
![]() |
![]() |
![]() |
#9 |
Sep 2002
Database er0rr
5·29·31 Posts |
![]() |
![]() |
![]() |
![]() |
#10 |
Jun 2003
2·2,719 Posts |
![]()
This test will work with other seeds of the form 2*a*(a+1) like 4,12,24,40, etc..
Interestingly some of them fail for p=11, declaring it to be prime (for eg:- 60, 760) |
![]() |
![]() |
![]() |
#11 |
"Rashid Naimi"
Oct 2015
Remote to Here/There
2,341 Posts |
![]() |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Regex can test for prime numbers | retina | Programming | 8 | 2016-05-26 01:37 |
Conjectured Primality Test for Specific Class of Mersenne Numbers | primus | Miscellaneous Math | 1 | 2014-10-12 09:25 |
6 digit numbers and the mersenne numbers | henryzz | Math | 2 | 2008-04-29 02:05 |
LLT numbers, linkd with Mersenne and Fermat numbers | T.Rex | Math | 4 | 2005-05-07 08:25 |
A primality test for Fermat numbers faster than Pépin's test ? | T.Rex | Math | 0 | 2004-10-26 21:37 |