Determine the smallest positive integer which is a palindrome in precisely 3 consecutive bases (excluding base 10). What are the next two smallest positive integers with this property?
*** Any solution must have more than one digit in any given base. So, trivial solutions like (0)base 3, (2)base 5 or, (C)base 14 are not allowed.
*** "Excluding base 10" means that the sequence of bases 9,11,12 for example, does not count as a possibility and, the bases have to be truly consecutive and all be on one side or the other of 10.
DEFDBL A-Z
OPEN "conbs.txt" FOR OUTPUT AS #2
FOR a = 1 TO 22
FOR bs = a + 1 TO 23
v = a * (bs + 1)
PRINT #2, USING "############"; v;
PRINT #2, USING " ##"; bs;
PRINT #2, " ";
PRINT #2, USING " ##"; a; a
NEXT bs
FOR b = 0 TO 22
IF b > a THEN st = b + 1: ELSE st = a + 1
FOR bs = st TO 23
v = a * (bs * bs + 1) + b * (bs)
PRINT #2, USING "############"; v;
PRINT #2, USING " ##"; bs;
PRINT #2, " ";
PRINT #2, USING " ##"; a; b; a
NEXT bs
FOR bs = st TO 23
v = a * (bs * bs * bs + 1) + b * (bs * bs + bs)
PRINT #2, USING "############"; v;
PRINT #2, USING " ##"; bs;
PRINT #2, " ";
PRINT #2, USING " ##"; a; b; b; a
NEXT bs
FOR c = 0 TO 22
IF c + 1 > st THEN st2 = c + 1: ELSE st2 = st
FOR bs = st2 TO 23
v = a * (bs * bs * bs * bs + 1) + b * (bs * bs * bs + bs) + c * (bs * bs)
PRINT #2, USING "############"; v;
PRINT #2, USING " ##"; bs;
PRINT #2, " ";
PRINT #2, USING " ##"; a; b; c; b; a
NEXT bs
FOR bs = st2 TO 23
v = a * (bs * bs * bs * bs * bs + 1) + b * (bs * bs * bs * bs + bs) + c * (bs * bs * bs + bs * bs)
PRINT #2, USING "############"; v;
PRINT #2, USING " ##"; bs;
PRINT #2, " ";
PRINT #2, USING " ##"; a; b; c; c; b; a
NEXT bs
NEXT c
NEXT b
NEXT a
CLOSE
SHELL "sort < conbs.txt > conbs2.txt"
OPEN "conbs2.txt" FOR INPUT AS #1
DO
a$ = b$: b$ = c$
LINE INPUT #1, c$
IF LEFT$(a$, 12) = LEFT$(b$, 12) AND LEFT$(c$, 12) = LEFT$(b$, 12) THEN
a = VAL(MID$(a$, 14, 2))
b = VAL(MID$(b$, 14, 2))
c = VAL(MID$(c$, 14, 2))
IF b = a + 1 AND c = b + 1 THEN
PRINT a$
PRINT b$
PRINT c$
PRINT
END IF
END IF
LOOP UNTIL EOF(1)
finds
decimal base representation
178 6 4 5 4
178 7 3 4 3
178 8 2 6 2
300 7 6 0 6
300 8 4 5 4
300 9 3 6 3
373 8 5 6 5
373 9 4 5 4
373 10 3 7 3
676 10 6 7 6
676 11 5 6 5
676 12 4 8 4
1111 12 7 8 7
1111 13 6 7 6
1111 14 5 9 5
1702 14 8 9 8
1702 15 7 8 7
1702 16 6 10 6
2473 16 9 10 9
2473 17 8 9 8
2473 18 7 11 7
3448 18 10 11 10
3448 19 9 10 9
3448 20 8 12 8
4651 20 11 12 11
4651 21 10 11 10
4651 22 9 13 9
so the smallest such integer, in decimal, is 178, with base-6, 7 and 8 representations of 454, 343 and 262 respectively.
The next case is 300, where the base-7, 8 and 9 representations are 606, 454 and 363 respectively.
The next two cases involve base-10 and therefore are ruled out, so that the next sought case is decimal 1111, where base-12, 13 and 14 representations are 787, 676 and 595 respectively.
Further cases are also shown. Digits higher than 9 are shown coded as decimal, rather than the traditional A, B, etc.
|
Posted by Charlie
on 2013-12-04 17:56:33 |