![]() |
Oh, I see.
He mentioned several times, learning ASM but I think he needs first some basics in programming! [lifting up hat] Your patience is marvellous. |
[QUOTE=kar_bon;222573]Oh, I see.
He mentioned several times, learning ASM but I think he needs first some basics in programming! [lifting up hat] Your patience is marvellous.[/QUOTE] I know other languages I just suck and note I never once said I was logical I give up I'm hopeless when I found something acting up in his code I couldn't even figure it out. also I've tried the stuff in private but why post things that aren't worth while. [B]edit:[/B]just found it while beat CRG's code by about 31 ms for the equivalent of doing 1-1000,but I found it slows down a lot as his code by 100000 is like 3 times as fast to check half as much ? for(c=2,500,for(n=0,c-3,if(isprime(c-n) && isprime(c+n),print(c","n);break()))) anyway you can speed this up ? |
[QUOTE=science_man_88;222626]for(c=2,500,for(n=0,c-3,if(isprime(c-n) && isprime(c+n),print(c","n);break()))) anyway you can speed this up ?[/QUOTE]
What is it trying to do? |
[QUOTE=CRGreathouse;222677]What is it trying to do?[/QUOTE]
it's checking if c+n and c-n is prime for any n if one is found it prints it then jumps to the next n. |
[QUOTE=science_man_88]it's checking if c+n and c-n is prime for any n if one is found it prints it then jumps to the next n.[/QUOTE]
Is it a loop in the first place? |
[QUOTE=3.14159;222680]Is it a loop in the first place?[/QUOTE]
yes but if I don't break after the first one I have to waste time finding more of them for each c value. |
Notice that c and n need to be of opposite parity... that'll save a few cycles.
|
[QUOTE]Notice that c and n need to be of opposite parity... that'll save a few cycles.
[/QUOTE] Idle cycles? |
[QUOTE=CRGreathouse;222692]Notice that c and n need to be of opposite parity... that'll save a few cycles.[/QUOTE]
unless I do a if statement outside the second loop to determine the starting of a forstep loop equivalent to the second one I don't know how to do it. last result computed in 4,328 ms.<- my updated code to 500,000 (which checks evens effectively to 1 Million) last result computed in 49,266 ms.<- your gold(n) code to 1 million second test of my code gave -500 on my first test of it I think. I should test all codes given so far. *** last result computed in 3,812 ms. is my second test with CRGreathouses optimizations |
[QUOTE=science_man_88;222695]last result computed in 4,328 ms.<- my updated code to 500,000 (which checks evens effectively to 1 Million)
last result computed in 49,266 ms.<- your gold(n) code to 1 million[/QUOTE] Please post both scripts so I can compare! |
last result computed in 47,531 ms. <- second run of gold(n)
note: your earlier codes looked more promising than mine does now |
| All times are UTC. The time now is 04:47. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.