Find the lowest positive integer that has its digits reversed after dividing it by 2.
(In reply to
Solution by Tristan)
If all bases are allowed then in base 5, 31/2 = 13, which in decimal comes out to 16/2 = 8.
The results of a computer program that checked numbers up to the previously found 64(decimal) found:
base 5 ; 31 13; decimal 16 8
base 8 ; 52 25; decimal 42 21
base 3 ; 2101 1012; decimal 64 32
The program:
CLS
digits$ = "0123456789abcdefghijklmnopqrstuvwxyz"
FOR n = 1 TO 32
b = 2
DO
n$ = "": n2$ = "": n2 = 0
t = n
DO
d = t MOD b
t = t \ b
dig$ = MID$(digits$, d + 1, 1)
n$ = dig$ + n$
n2$ = n2$ + dig$
n2 = n2 * b + d
LOOP UNTIL t = 0
IF n2 = 2 * n THEN
PRINT "base"; b; "; "; n2$; " "; n$; "; decimal "; n2; n
END IF
b = b + 1
LOOP UNTIL LEN(n$) = 1
NEXT
|
Posted by Charlie
on 2004-07-15 23:06:27 |