![]() |
[QUOTE=CRGreathouse;227567]Instead of testing if n+1 is a prime, I loop through the primes, choosing n = p-1 so that n+1 is prime. Because I'm using Pari's precalculated list instead of testing numbers, the search is much faster. (This occurs even if I have to generate the whole list myself -- sieving is much faster than testing.)[/QUOTE]
my brain must have been switched off before lol. |
[QUOTE=CRGreathouse]Instead of testing if n+1 is a prime, I loop through the primes, choosing n = p-1 so that n+1 is prime. Because I'm using Pari's precalculated list instead of testing numbers, the search is much faster. (This occurs even if I have to generate the whole list myself -- sieving is much faster than testing.)[/QUOTE]
This renders you unable to test for larger numbers. |
[QUOTE=science_man_88;227569]outside of the fact that if you want them in order it's unlikely with my alteration wouldn't it be faster to say [CODE]n=p-1;a^2=p-1;b^4=p-1[/CODE] to check 3 at once ? though this would take 3 times the memory I think.[/QUOTE]
That wouldn't work. First, you can't assign to a^2 (in C terminology, it's an rvalue not an lvalue; in assembly terms (though not strictly relevant here!), it's not memory-mapped). Second, you can't fix more than one member -- once you pick one, you fix the values for all of them. |
[QUOTE=CRGreathouse;227571]That wouldn't work.[/QUOTE]
Yep, he's discovered! ... and deleted! |
[code]1546750398064958524633425292455441988676752527730835687139862311217981986247572619886186890734016949799686352443760408934653066300968034776190705901570570913201114184380563243205276690363368824249952639567750758594330067937015662345505149388718977581056000000000000000000000000000000000000000000000001[/code]
76, 151, 301 digits, new record for Number, square, and fourth. |
[QUOTE=3.14159;227570]This renders you unable to test for larger numbers.[/QUOTE]
As long as you're working below 4e9 or 1e10 or so (depending on your platform), it's *far* more efficient to use forprime. Further, for any number for which it is viable to generate all members up to, it's most efficient to sieve in some form. You could be talking about running overnight vs. taking a week. Of course this would take custom code! I happen to have this: prototype code that lets me loop over primes up to primelimit^2 rather than primelimit. I'm not going to release it at this time: it's buggy near the endpoints and I need to fix that, plus it requires a dynamic installation of Pari so doesn't work for people who only have the Windows binary. |
[QUOTE=CRGreathouse]Further, for any number for which it is viable to generate all members up to, it's most efficient to sieve in some form. You could be talking about running overnight vs. taking a week. Of course this would take custom code!
[/QUOTE] Or a download of an already existing implementation of the sieve. |
Well, one may already exist in form of a sieve for Generalized Fermat numbers. All that is required is sieving for n^2 + 1 and n^4 + 1
|
[QUOTE=3.14159;227576]Or a download of an already existing implementation of the sieve.[/QUOTE]
Do you know of any good out-of-memory sieves? |
[QUOTE=CRGreathouse]Do you know of any good out-of-memory sieves?
[/QUOTE] Well, I have a program that sieves for Generalized Fermats. You could sieve for n^2 + 1 and n^4 + 1 and take whatever elements both files have in common. |
[QUOTE=3.14159;227579]Well, I have a program that sieves for Generalized Fermats. You could sieve for n^2 + 1 and n^4 + 1 and take whatever elements both files have in common.[/QUOTE]
In a pinch, I suppose that works. You just test the remainder for primality of n+1, I suppose? |
| All times are UTC. The time now is 23:13. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.