QB / QB64 Discussion Forum      Other Subforums, Links and Downloads
 

 Return to Index  

a misunderstanding, perhaps?

June 12 2011 at 8:08 PM
  (Login MCalkins)
R


Response to Changing the formula in the middle of the sequence is just not Kosher!

 

I could be wrong, but I sense a little mutual hostility here. I guess it's partly attributable to personality differences.

I'm wondering if there is a misunderstanding. Clippy seems to be thinking that lawgin changed the formula midway through the sequence. I think he is referring to the

IF p > 4 THEN a = a + 9

line. I haven't examined lawgin's and qbguy's programs enough to understand how they work, but there is no trickery in the sequence. It is just a plain, straight-forward sequence of least common multiples. Just because the code that is used to generate it seems obscure doesn't mean that the sequence itself is somehow not straight forward. Obviously, the challenge was solvable, because it was solved.

This code, although slow and inefficient, should generate the same sequence:

DEFLNG A-Z
CLS
n = 1
FOR i = 1 TO 20
DO
FOR x = 1 TO i
IF n MOD x THEN n = n + 1: EXIT FOR
NEXT
IF x > i THEN PRINT n: EXIT DO
LOOP
NEXT

Regards,
Michael

P.S. I just looked at lawgin's code a little closer. The operation of his code is very similar to the program I have above. The

a = a + 1
IF p > 4 THEN a = a + 9

is just an optimization to make it start incrementing by 10 instead of 1 to save time.


    
This message has been edited by MCalkins on Jun 12, 2011 8:18 PM


 
 Respond to this message   
Responses

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement