20120623, 05:05  #1 
May 2004
2^{2}·79 Posts 
pari's capabality
I tried running the following program
{p(n)=isprime(n^2+1))} It runs satisfactorily only till about n= 5000; beyond that pari does not seem to be able to handle. 
20120623, 11:46  #2 
"Forget I exist"
Jul 2009
Dumbassville
10000011000000_{2} Posts 
what version might be useful to some others here ( not me personally)? both versions I have seem to work for up to n=50000 at least.
Last fiddled with by science_man_88 on 20120623 at 12:06 
20120623, 15:03  #3 
"Forget I exist"
Jul 2009
Dumbassville
2^{6}×131 Posts 
doh I see now it works just slower than you wanted I guess. one thing I see that could speed speed it up is the fact that x^2 mod 6 > 1,4,3,4,1,0 repeating so for x^2+1 to be 1 or 5 mod 6 ( the only ones that can be prime for numbers >3) if(x mod 2 == 1,return 0)
Last fiddled with by science_man_88 on 20120623 at 15:41 
20120624, 13:13  #4 
Dec 2008
you know...around...
1001110010_{2} Posts 
It works fine for me.
Last fiddled with by mart_r on 20120624 at 13:13 
20120624, 17:34  #5 
"Forget I exist"
Jul 2009
Dumbassville
2^{6}·131 Posts 
I'm guessing you've already picked up on the fact that n<n^2+1 which sounds trivial but can be used, this shows that when y^2+1 is prime all indexes greater than that that fall in the groups y or y mod y^2+1 are divisible by it I believe so as you find primes you can eliminate a lot from the search without primes outside the sequence.

20120624, 18:43  #6 
"Forget I exist"
Jul 2009
Dumbassville
2^{6}·131 Posts 
I've got a code that runs in 2527 seconds in 2.4.2 and 1921 seconds in 2.5.1 by the looks of it:
Code:
a=vector(9000000,x,1);for(y=1,#a,if(a[y]==1,if(isprime(y^2+1),forstep(z=(y^2+1)y,#a,[2*y,(y^2+1)(2*y)],if(z%(y^2+1)==y  z%(y^2+1)==y,a[z]=0)),a[y]=0),next()));a Last fiddled with by science_man_88 on 20120624 at 19:00 
Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Pari/GP to PFGW  carpetpool  Programming  6  20171221 06:04 
LLL in GP/Pari  paul0  Programming  2  20151117 13:04 
PARI vs GAP  skan  Miscellaneous Math  0  20121216 00:13 
pari  devarajkandadai  Programming  21  20120831 18:08 
64bit Pari?  CRGreathouse  Software  2  20090313 04:22 