|
Post by Gordon on Mar 18, 2009 7:32:38 GMT -5
Someone tested this listing with RB and LB
cls:print time$() for priem=999999999901 to 999999999999 step 2 for deler=3 to sqr(priem) step 2 if priem mod deler = 0 then exit for next deler if priem mod deler = 0 then [geenPriem] print priem [geenPriem] next priem print time$() end
LB works slowly but flawless RB runs fast but makes two misstakes
Gordon
|
|
|
Post by Gordon on Mar 21, 2009 7:22:51 GMT -5
Are there some differences between the sqr function or the mod function of RB and LB?
Gordon
This listing gives two wrong answers in RB
|
|
|
Post by Carl Gundel - admin on Mar 21, 2009 12:36:34 GMT -5
Sorry, I'll try to figure this out. Right now I don't have an answer.
-Carl
|
|
|
Post by Carl Gundel - admin on Mar 21, 2009 13:49:50 GMT -5
Okay, this is a very strange bug in the FOR/NEXT loop. For some reason your posted program it is not stepping by 2. The following works as expected but the code you provided acts as though there is no step 2: for priem=999999999901 to 999999999999 step 2 print priem next priem Here is a reworked program that works correctly: cls:print time$() priem=999999999901 while priem <= 999999999999 for deler=3 to sqr(priem) step 2 if priem mod deler = 0 then exit for next deler if priem mod deler = 0 then [geenPriem] print priem [geenPriem] priem = priem + 2 wend print time$() end What's encouraging about this is that the reworked program is even faster than the version you posted. I will get to the bottom of this. THANKS for posting this bug. -Carl
|
|