![]() |
|
|
#243 | |
|
"Forget I exist"
Jul 2009
Dumbassville
100000110000002 Posts |
Quote:
Code:
a=0;for(p=1,x,if(isprime(p) && isprime(2^p-1),a=a+1;print(p);if(a==n,break();)) |
|
|
|
|
|
|
#244 | |
|
May 2010
Prime hunting commission.
24×3×5×7 Posts |
Quote:
Also: @Sm88: Isn't it supposed to be Code:
a=0;forprime(p=1,x,if(isprime(p) && isprime(2^p-1),a=a+1;print(p);if(a==n,break();)) (My emphasis in red.) Last fiddled with by 3.14159 on 2010-08-11 at 15:51 |
|
|
|
|
|
|
#245 |
|
"Forget I exist"
Jul 2009
Dumbassville
100000110000002 Posts |
only if you know before hand x is under primelimit if it isn't forprime may not work as it uses primes[i] last I checked. so if you don't already have all the primes needed calculated it must calculate them on the fly and the isprime(p) would need to be eliminated if you use forprime as it's not needed until after exhausting primelimit.
Last fiddled with by science_man_88 on 2010-08-11 at 15:57 |
|
|
|
|
|
#246 | |
|
Aug 2006
3×1,993 Posts |
Quote:
But even if you were concerned only about numbers below 2^32 ~ 4e9, I still wouldn't recommend using a complicated inelegant method. Last fiddled with by CRGreathouse on 2010-08-11 at 15:58 |
|
|
|
|
|
|
#247 | |
|
Aug 2006
10111010110112 Posts |
Quote:
And if you did use forprime, you wouldn't need to have isprime(p), just isprime(2^p-1). |
|
|
|
|
|
|
#248 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Quote:
this is something the code creating script would have to figure out to give the most efficient codes. Last fiddled with by science_man_88 on 2010-08-11 at 16:03 |
|
|
|
|
|
|
#249 |
|
Jun 2003
5,087 Posts |
An interesting aside:
Code:
nu=valuation(f[1]-1,2); for(i=2,#f,nu=min(nu,valuation(f[i]-1,2)) Code:
nu=valuation(f-vectorv(#f,X,1),2) |
|
|
|
|
|
#250 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
Code:
(12:03) gp > nu=valuation(f-vectorv(#f,X,1),2) *** _-_: forbidden addition t_POL + t_COL. and your first one came back syntax errors then I fixed it and : Code:
(13:10) gp > for(i=2,#f,nu=min(nu,valuation(f[i]-1,2))) *** for: _[_]: not a vector. Code:
(13:12) gp > nu=valuation(f[1]-1,2);for(i=2,#f,nu=min(nu,valuation(f[i]-1,2))) *** _[_]: not a vector. Last fiddled with by science_man_88 on 2010-08-11 at 16:47 |
|
|
|
|
|
#251 |
|
"Forget I exist"
Jul 2009
Dumbassville
838410 Posts |
so
1)read(post) 2)dissect the post into parts we can search addhelp() with for a function that it will solve it 3) post it on the forum ? |
|
|
|
|
|
#252 |
|
May 2010
Prime hunting commission.
24×3×5×7 Posts |
Excellent.
A small inconvenience: Here is a code snippet that allows me to search for 2nd kind Cunningham semiprimes (Of the form 2p2-p that are pseudoprime to base 2): Code:
modbmpsp(x,n,m)=if(isPRP(modbm(x,n,m),b=2),print(modbm(x,n,m)) Code:
***Mod: division by zero. Code:
isPRP(n,b=2)={
my(s=valuation(n-1,2),d=n>>s);
n=Mod(b,n)^d;
if(n==1,return(1));
while(s--,
if(n==-1,return(1));
n=n^2
);
n==-1
};
Last fiddled with by 3.14159 on 2010-08-11 at 17:54 |
|
|
|
|
|
#253 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
Quote:
Last fiddled with by science_man_88 on 2010-08-11 at 18:04 |
|
|
|
|
![]() |
| Thread Tools | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Why do I sometimes see all the <> formatting commands when I quote or edit? | cheesehead | Forum Feedback | 3 | 2013-05-25 12:56 |
| Passing commands to PARI on Windows | James Heinrich | Software | 2 | 2012-05-13 19:19 |
| Ubiquity commands | Mini-Geek | Aliquot Sequences | 1 | 2009-09-22 19:33 |
| 64-bit Pari? | CRGreathouse | Software | 2 | 2009-03-13 04:22 |
| Are these commands correct? | jasong | Linux | 2 | 2007-10-18 23:40 |