Code: Select all
!XOR edx,edx
MOV eax,3
While eax < 1000
ADD edx,eax
ADD eax,3
Wend
MOV eax,5
While eax < 1000
ADD edx,eax
ADD eax,15
Wend
MOV eax,10
While eax < 1000
ADD edx,eax
ADD eax,15
Wend
a !DB
MOV a,edx
Debug a
Code: Select all
!XOR edx,edx
MOV eax,3
While eax < 1000
ADD edx,eax
ADD eax,3
Wend
MOV eax,5
While eax < 1000
ADD edx,eax
ADD eax,15
Wend
MOV eax,10
While eax < 1000
ADD edx,eax
ADD eax,15
Wend
a !DB
MOV a,edx
Debug a
Code: Select all
While eax < 1000
ADD edx,eax
ADD eax,15
Wend
Code: Select all
While eax < 1000
SUB edx,eax
ADD eax,15
Wend
There is mention of a pseudo-prime test on the Project Euler forum, but to be honest I haven't been able to get my head around how that works yet.dioxin wrote:I think to start with you need a much more efficient IsPrime() function and a more efficient find next prime function.
Hi Francis,Dreamland Fantasy wrote: A simple trick to completing it really fast is to create a function that will check n^2 + 1, n^2 + 3, n^2 + 7, etc.. for primes simultaneously rather than doing them individually with IsPrime().
Yeah, I've saved the pre-calculated primes upto 150000000 on my computer at home, but it's quite a big file (too big for my memory stick)!Michael Vogel wrote:Just used my old code (seen in page 8 of the thread, so I also check all terms in the IsPrimeChain() at the beginning) - so the only real change is that I have removed the precalculation of primes (saved it to a file)![]()
Hey Francis, you are #1! (not only because you started with this problem)Dreamland Fantasy wrote:Yeah, I've saved the pre-calculated primes upto 150000000 on my computer at home, but it's quite a big file (too big for my memory stick)!![]()
I redone the pre-calculations and saved them on this computer and redoing the problem it completes in 15.6 seconds (P4 @ 1.6GHz)! Pre-calculating to 79000 and doing the rest on the fly takes 64.4 seconds, so it's a big speed boost!
I was looking forward to trying out the code on my machine at home, but unfortunately I left my memory stick at work. Doh! :roll: In theory it should take about 2 seconds give or take on my quad-core system. Quite impressive I think considering my original approach took over 4 days!Michael Vogel wrote:Hey Francis, you are #1! (not only because you started with this problem)Dreamland Fantasy wrote:Yeah, I've saved the pre-calculated primes upto 150000000 on my computer at home, but it's quite a big file (too big for my memory stick)!![]()
I redone the pre-calculations and saved them on this computer and redoing the problem it completes in 15.6 seconds (P4 @ 1.6GHz)! Pre-calculating to 79000 and doing the rest on the fly takes 64.4 seconds, so it's a big speed boost!
Never will get these results, precalculation takes about two or three minutes here! (Maybe you can PM me your code;), I saved the primes only, which takes about 33MB when using long values...
Again, 16 (and also 64) seconds are great!
Michael
I'm doing this independently, but I do try to help out others if I can as well as asking for help myself if I need a nudge in the right direction.pdwyer wrote:Are you guys doing some sort of group entry for this or are you all submitting independantly? This looks kind of fun.
I'm wondering if this is a collaborative effort or you are just sharing notes as you go
Try having a look at http://www.csn.ul.ie/~darkstar/assembler/.michaeled314 wrote::roll: :roll:michaeled314 wrote::roll:michaeled314 wrote:How on earth would you do #2 in ASM