QB / QB64 Discussion Forum      Other Subforums, Links and Downloads
 

 Return to Index  

The English Version

June 11 2011 at 6:37 PM
lawgin  (no login)


Response to Seems to work

 

The ever obtuse and smug qbguy did get the correct answer, to his credit.

Each number is the least common multiple according to it's position in the sequence or, stated differently, each number is the smallest integer which is evenly divisible by all the integers up to it's position in the sequence.

1, 2, 6, 12, 60, 60, 420, 840, 2520

1 is the smallest integer evenly divisible by 1
2 is the smallest integer evenly divisible by 1 and 2
6 is the smallest integer evenly divisible by 1, 2, and 3
12 is the smallest integer evenly divisible by 1, 2, 3, and 4
etc.

Below is the code I used to produce the sequence, though it craps out after 22 terms due to an overflow.

CLS
DEFLNG A
DO
p = p + 1
DO
a = a + 1
IF p > 4 THEN a = a + 9
FOR b = 2 TO p
IF a MOD b <> 0 THEN EXIT FOR
NEXT
IF b = p + 1 THEN
PRINT a;
a = 0
EXIT DO
END IF
LOOP
LOOP


 
 Respond to this message   
Responses

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