![]() |
|
|
#166 |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Code:
Goldbach(n)={
my(nn=n+n);
forprime(x=2,n,if(isprime(nn-x),return(x)));
0
};
GoldbachMax(n)={
my(nn=n+n);
forprime(x=2,default(primelimit),if(isprime(nn-x),return(x)));
error("Ran out of primes at "n)
};
test(lim,startAt=2)={
my(breakpoint=min(lim\2,default(primelimit)));
startAt=floor(startAt);
for(n=startAt,breakpoint,
if(Goldbach(n),print1(2*n,","))
);
for(n=max(startAt,breakpoint+1),lim\2,
if(GoldbachMax(n),print1(2*n,","))
)
};
Code:
Gold(n)={
forprime(x=2,n/2,
f=floor((.5*n-x)+(.5*n));
if(isprime(f),
print(x","f","n);
return();
);
)
};
forstep(n=2,400,2,Gold(n))
and mine = for(c=2,500,for(n=0,c-3,if(isprime(c-n) && isprime(c+n),print(c","n);break()))) originally from what I just posted on. and my best improvement is: for(c=2,500,if(c%2==0,forstep(n=1,c-3,[2],if(isprime(c-n) && isprime(c+n),print(c","n);break())));if(c%2==1,forstep(n=2,c-3,[2],if(isprime(c-n) && isprime(c+n),print(c","n);break()))))<- double checking the time for. I messed it up as I swear it said 4000 last time but it says 50,000 now anyone willing to test it ? Last fiddled with by science_man_88 on 2010-07-25 at 01:08 |
|
|
|
|
|
#167 |
|
Aug 2006
3×1,993 Posts |
Printing takes a lot of time -- remove the print statements if you want to compare!
The second piece of code you posted, Gold(n), is just my cleaned-up version of your code; it's not fast. The first one, apart from the print instructions, is fast. In my test it's more than ten times faster than yours -- 2.7 seconds to get to a million vs. 47 seconds for your old version or 40 seconds for your new version. Code:
Goldbach(n)={
my(nn=n+n);
forprime(x=2,n,if(isprime(nn-x),return(0)));
1
};
GoldbachMax(n)={
my(nn=n+n);
forprime(x=2,default(primelimit),if(isprime(nn-x),return(0)));
error("Ran out of primes at "n)
};
test(lim,startAt=2)={
my(breakpoint=min(lim\2,default(primelimit)));
startAt=floor(startAt);
for(n=startAt,breakpoint,
if(Goldbach(n),print1(2*n,","))
);
for(n=max(startAt,breakpoint+1),lim\2,
if(GoldbachMax(n),print1(2*n,","))
)
};
sm88(lim)={
for(c=2,lim,for(n=0,c-3,if(isprime(c-n)&&isprime(c+n),break)))
};
sm88a(lim)={
for(c=2,lim,
if(c%2==0,
forstep(n=1,c-3,[2],if(isprime(c-n) && isprime(c+n),break))
);
if(c%2==1,
forstep(n=2,c-3,[2],if(isprime(c-n) && isprime(c+n),break))
)
)
};
Last fiddled with by CRGreathouse on 2010-07-25 at 01:16 |
|
|
|
|
|
#168 |
|
May 2010
Prime hunting commission.
32208 Posts |
Cheesehead. Do you also visit the kook section regularly?
Last fiddled with by 3.14159 on 2010-07-25 at 01:54 |
|
|
|
|
|
#169 |
|
Aug 2006
3·1,993 Posts |
Actually, the numbers I posted above were bad (comparing the wrong things). Running my test to 2e6 is the proper comparison to running yours to 1e6, so my time is 5.9 seconds; 6 or 7 times faster than yours, not "more than 10 times".
|
|
|
|
|
|
#170 |
|
"Forget I exist"
Jul 2009
Dumbassville
20C016 Posts |
well any combination of 6n-1,6n+1 will give a even number so it comes down to the probability of 2 aligning within x-3 either side of the given number such that both are prime.
|
|
|
|
|
|
#171 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
Code:
for(x=4,2^30,if(isprime(x) && nextprime(x)-x>(x-3),print(x))) Last fiddled with by science_man_88 on 2010-08-09 at 12:27 |
|
|
|
|
|
#172 | |
|
Aug 2006
175B16 Posts |
Quote:
Ramanujan proved this in 1919 and possibly earlier. Last fiddled with by CRGreathouse on 2010-08-09 at 13:05 |
|
|
|
|
|
|
#173 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
theres only one in my image that skips any 6n+1 6n-1 numbers at all from the first one below I don't get why it couldn't have been solved.
|
|
|
|
|
|
#174 | |
|
Aug 2006
597910 Posts |
Quote:
Code:
for(x=4,N,if(isprime(x) && nextprime(x)-x>(x-3),print(x))) |
|
|
|
|
|
|
#175 |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
I know that's what you meant as only one part of my image doesn't hit every 6n+1/-1 number either direction last I checked it should be simple to prove Goldbach's conjecture
|
|
|
|
|
|
#176 | |
|
Aug 2006
135338 Posts |
Quote:
|
|
|
|
|
![]() |
| Thread Tools | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Goldbach Conjecture | MattcAnderson | MattcAnderson | 4 | 2021-04-04 19:21 |
| Factorial and Goldbach conjecture. | MisterBitcoin | MisterBitcoin | 17 | 2018-01-29 00:50 |
| Goldbach's weak conjecture | MattcAnderson | MattcAnderson | 19 | 2017-03-21 18:17 |
| Goldbach's conjecture | Citrix | Puzzles | 3 | 2005-09-09 13:58 |