![]() |
|
|
#23 | |
|
Romulan Interpreter
Jun 2011
Thailand
100101100001102 Posts |
Quote:
I know this is only tangent connected, but I already complained to you few times, mersenne.ca will tell me every time I search for a factor which is not in the data base, that the factor is not in the data base. It would be very easy and fast to check if that is a valid factor, and in case it is, add it to the data base together with the exponent that results from that calculus. Usually I don't add factors to mersenne.ca, i.e. I report them to PrimeNet and let mersenne.ca deal with it. However I look to mersenne.ca quite often to see properties of the factors (like their smoothness of k, size in bits, etc) - those reports look much better there than I could see using pari (like "#binary(factor)", etc). Therefore it would be very useful if, when somebody search for a factor and you can not find it in the db, you then run something like Code:
getpfp(n)=
{
if(!isprime(n),return(0));
my(c);
c=divisors(n-1);
for(i=1,#c,
if(c[i]<1000000000 && Mod(2,n)^c[i]==1, return(c[i]))
);
return(0);
}
|
|
|
|
|
|
|
#24 | ||
|
"James Heinrich"
May 2004
ex-Northern Ontario
19×179 Posts |
There is now an export option available for those who need it. PM me if you want access.
I don't recall you ever mentioning this before... Quote:
![]() Quote:
Validating a factor to a known exponent is easy and fast. Validating a known factor to (maybe) one of ~200-million potential exponents I don't think can be described as "fast". As a one-off issue when LaurV queries an unknown factor that's fine, but I'm not quite sure how to safeguard it. Suggestions? |
||
|
|
|
|
|
#25 |
|
Jun 2003
33×11×17 Posts |
|
|
|
|
|
|
#26 |
|
"James Heinrich"
May 2004
ex-Northern Ontario
19·179 Posts |
|
|
|
|
|
|
#27 |
|
"Forget I exist"
Jul 2009
Dumbassville
20C016 Posts |
I wouldn't think faster except LaurV's code allows the testing of all possible p values that the factor could be a divisor of. if factors q-1 and gets the factorization of 2*k*p into primes back for all p values it could possibly be a candidate factor of. I could think of other optimizations of the code like eliminating p if the remaining factorization isn't of the proper modular class etc.
|
|
|
|
|
|
#28 |
|
Romulan Interpreter
Jun 2011
Thailand
226068 Posts |
If you ignore the two primality tests (one for factor, one for result) and the limit check (which would be 2^32 for James, not 1G as in my example) and consider the argument always prime, then yes, my routine is faster. The limit will also avoid testing for larger divisors, gaining more time either. They are done about the same internally; znorder needs to know the divisors list (it gets slower for a non-prime, where my routine without isprime() will fail, returning a wrong result). Otherwise we would have a very fast way to factor numbers by invoking znorder so.
However, faster or not, my piece of code give James an insight if he wants a perl or php implementation (to which I know he is very good), versus znorder which he may not know what is it or how to php it. The isprime() test is not included in my initial routine (but the <1G test is) and I added it "on spot" when I did the paste, because I assumed someone can try reporting factors which are not prime. The name itself says "get the p from a prime q" where q is a (known) factor of (an unknown) m=2^p-1. (you may recall that I keep this notation in all my posts). This as opposite of the general "getp()" which will accept a non-prime argument too, but is slower (same speed as znorder). edit: re SM's post: that is bull edit 2: re "I don't recall you ever mentioning this before...", it is on the posts where I was talking about "factoring by k". This is what is doing, take a k, compute 2kp+1, get its order, if prime, we found a factor. There I mentioned about searching for previously unknown factors on mersenne.ca (by searching I mean I press the search button and type my new-found factor, the site should do an evaluation and give me the p, instead of telling me "factor not found") Last fiddled with by LaurV on 2016-06-17 at 10:51 |
|
|
|
|
|
#29 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
well that's what your code allows if you tested n to see if it's not 3 or 5 mod 8 or some other modular classes you could speed it up even more potentially, factoring n-1 is going to give you 2*k*p 's factorization extract a new p from the possibility list and it allows you to test divisibility for all of them. I'm wondering what you think it bull ?
Last fiddled with by science_man_88 on 2016-06-17 at 10:57 |
|
|
|
|
|
#30 |
|
Romulan Interpreter
Jun 2011
Thailand
2×3×1,601 Posts |
First because "LaurV's code allows the testing of all possible p values that the factor could be a divisor of" is not needed, two mersenne with prime exponents can't share a factor, so you stop at the first p. Second, that is what znorder does too, it factors q-1. About optimizations, we were not discussing finding factors, this piece of code and other even more optimized I posted in the past here:
Code:
/* trial factoring by k, specify a starting point and the outfput file */
ratf(q=2,fis="mf_by_k.out")=
{
while(1,
until(q%8==1 || q%8==7,q=nextprime(q+1));
c=factorint(q-1)[,1]~;
for(i=1,#c,
if(c[i]<1000000000 && Mod(2,q)^c[i]==1, print(q" divides M"c[i]); write(fis,q","c[i]))
)
);
}
Last fiddled with by LaurV on 2016-06-17 at 11:19 |
|
|
|
|
|
#31 |
|
"James Heinrich"
May 2004
ex-Northern Ontario
65118 Posts |
|
|
|
|
|
|
#32 | |
|
Romulan Interpreter
Jun 2011
Thailand
2×3×1,601 Posts |
Quote:
![]() Good job, thanks a lot. I go to bed now (23:40 here) and tomorrow is my working Saturday (here we work alternating Sat's) |
|
|
|
|
|
|
#33 |
|
"James Heinrich"
May 2004
ex-Northern Ontario
19·179 Posts |
Any suggestions for how to fully factor moderately-large (50-150 digit) numbers? I run into these most often as k values, and the ones that are <50 digits I can factor pretty much instantly, but the large ones can take some time. Until now I've just been aborting and saying "too large" and not showing the relevant details, but I've now started collecting them in hopes of finding some kind of offline processing. I've manually tried a few of them with Dario's Java ECM tool, and some are factored within a second while others (e.g. "5272703229220007874811133810104969405477368739513286723394714036551930163895517204360421097050187418157101219550018359697836") have been crunching for more than 5 hours already. So I'd like to find some kind of offline tool that runs under Windows where I can feed it a list of presumably-composite numbers and let it chew on them and spit out the factorization. Suggestions?
|
|
|
|
![]() |
| Thread Tools | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ECM on small Mersenne Numbers | Erich | PrimeNet | 16 | 2012-09-29 23:08 |
| Can two Mersenne numbers share a factor? | James Heinrich | Math | 57 | 2011-09-12 14:16 |
| mersenne prime as a factor of another number | kurtulmehtap | Math | 21 | 2010-11-08 18:21 |
| Mersenne factor | bitblit | Math | 3 | 2009-05-02 01:20 |
| Fast calculations modulo small mersenne primes like M61 | Dresdenboy | Programming | 10 | 2004-02-29 17:27 |