All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 A Bit of a Problem (Posted on 2004-12-07)
Find the pattern of the following sequence and determine the next few terms:
`2, 10, 12, 38, 42, 52, 56, 142, 150, 170`

 See The Solution Submitted by DJ Rating: 4.0000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 re: Hints | Comment 7 of 17 |
(In reply to Hints by DJ)

Continuing Larry's solution yields the same numbers as in DJ's hint:

`2 :10                   1 , 010 :1010                2 , 112 :1100                3 , 038 :100110              4 , 342 :101010              5 , 252 :110100              6 , 156 :111000              7 , 0142 :10001110           8 , 7150 :10010110           9 , 6170 :10101010           10 , 5178 :10110010           11 , 4204 :11001100           12 , 3212 :11010100           13 , 2232 :11101000           14 , 1240 :11110000           15 , 0542 :1000011110         16 , 15558 :1000101110         17 , 14598 :1001010110         18 , 13614 :1001100110         19 , 12666 :1010011010         20 , 11682 :1010101010         21 , 10722 :1011010010         22 , 9738 :1011100010         23 , 8796 :1100011100         24 , 7812 :1100101100         25 , 6852 :1101010100         26 , 5868 :1101100100         27 , 4920 :1110011000         28 , 3936 :1110101000         29 , 2976 :1111010000         30 , 1`

produced by the program

n1 = 1
n2 = 0
FOR n1 = 1 TO 30
n1\$ = ""
n = n1
DO
n1\$ = LTRIM\$(STR\$(n MOD 2)) + n1\$
n = n \ 2
LOOP UNTIL n = 0
IF INSTR(MID\$(n1\$, 2), "1") = 0 THEN
n2 = n1 - 1
ELSE
n2 = n2 - 1
END IF
n2\$ = ""
n = n2
DO
n2\$ = n2\$ + LTRIM\$(STR\$(n MOD 2)) ' made in reverse
n = n \ 2
LOOP UNTIL n = 0
DO UNTIL LEN(n2\$) = LEN(n1\$)
n2\$ = n2\$ + "0"
LOOP
n = 0: n\$ = n1\$ + n2\$
FOR i = 1 TO LEN(n\$)
n = 2 * n + VAL(MID\$(n\$, i, 1))
NEXT
PRINT n; ":"; n\$; TAB(25); n1; ","; n2
NEXT

As a measure of complexity, a subjective matter, this program is longer than the program which produced my interpretation.

 Posted by Charlie on 2004-12-09 19:57:42

 Search: Search body:
Forums (0)