Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > Re: Euler probl...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 22 of 22 Topic 4048 of 4325
Post > Topic >>

Re: Euler problem #187

by Bernd Paysan <bernd.paysan@[EMAIL PROTECTED] > May 18, 2008 at 01:24 AM

William James wrote:
>>
>> : PRIMES  ( -- n )
>>     FLAGS plimit 2/ 1 FILL
>>     3  EFLAG FLAGS DO

For speed, please run the outer loop only between FLAGS and
FLAGS+sqrt(plimit)/2. This is completely sufficient, as any non-prime is
already dividable by one number that's at most the square of plimit, so
after that, you'll never mark any new number as non-prime. This "small"
optimization improves the algorithm of sieve from O(n^1,5) to O(n), which
is a huge advantage if your n is 100 millions. The benchmark was never
optimized, since one idea of a benchmark is to run the same stupid thing,
and not change the rules.

> forprime( pr=2, sqrtint( top - 1 ),

Yes, that's the right end here.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://www.jwdt.com/~paysan/
 




 22 Posts in Topic:
[SPOILER] Re: Euler problem #187
anton@[EMAIL PROTECTED]   2008-05-09 20:27:46 
Re: [SPOILER] Re: Euler problem #187
mhx@[EMAIL PROTECTED] (M  2008-05-10 00:42:26 
Re: [SPOILER] Re: Euler problem #187
cac <cac@[EMAIL PROTEC  2008-05-09 16:23:19 
Re: [SPOILER] Re: Euler problem #187
anton@[EMAIL PROTECTED]   2008-05-10 09:43:00 
Re: [SPOILER] Re: Euler problem #187
mhx@[EMAIL PROTECTED] (M  2008-05-10 12:45:19 
Re: [SPOILER] Re: Euler problem #187
anton@[EMAIL PROTECTED]   2008-05-10 13:11:43 
Re: [SPOILER] Re: Euler problem #187
mhx@[EMAIL PROTECTED] (M  2008-05-10 19:29:58 
Counted loops (was: [SPOILER] Re: Euler problem #187)
anton@[EMAIL PROTECTED]   2008-05-10 17:34:43 
Re: [SPOILER] Re: Euler problem #187
mhx@[EMAIL PROTECTED] (M  2008-05-10 20:10:28 
Re: [SPOILER] Re: Euler problem #187
Luca Masini <lmasini@[  2008-05-10 23:54:21 
Re: [SPOILER] Re: Euler problem #187
mhx@[EMAIL PROTECTED] (M  2008-05-11 00:58:55 
more euler problems, was Re: Euler problem #187
Albert van der Horst <  2008-05-12 14:21:47 
[SPOILER] Re: more euler problems
anton@[EMAIL PROTECTED]   2008-05-12 18:43:32 
Re: [SPOILER] Re: more euler problems
cac <cac@[EMAIL PROTEC  2008-05-12 13:26:55 
Re: [SPOILER] Re: more euler problems
anton@[EMAIL PROTECTED]   2008-05-13 10:14:55 
Re: [SPOILER] Re: more euler problems
cac <cac@[EMAIL PROTEC  2008-05-13 10:16:55 
Re: [SPOILER] Re: more euler problems
anton@[EMAIL PROTECTED]   2008-05-13 18:22:29 
Re: [SPOILER] Re: more euler problems
cac <cac@[EMAIL PROTEC  2008-05-13 12:25:24 
Re: more euler problems, was Re: Euler problem #187
William James <w_a_x_m  2008-05-17 16:40:44 
Re: [SPOILER] Re: Euler problem #187
William James <w_a_x_m  2008-05-17 17:01:57 
Re: Euler problem #187
William James <w_a_x_m  2008-05-17 15:18:54 
Re: Euler problem #187
Bernd Paysan <bernd.pa  2008-05-18 01:24:16 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 17:14:10 CST 2008.