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

 Positively Palindromic (Posted on 2014-04-06)
Determine the smallest positive integer each of whose base 6, base 8 and base 9 representations is a palindrome.

*** Any solution must contain more than one digit in any given base. So, trivial solutions like (2)base 8 or, (7)base 9 are not allowed.

 No Solution Yet Submitted by K Sengupta No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 solution Comment 2 of 2 |

154  where the base representations are:

414 232 181

DECLARE FUNCTION basen\$ (x!, n!)
DECLARE FUNCTION isPalin! (s\$)
FOR n = 10 TO 999999
IF isPalin(basen\$(n, 6)) AND isPalin(basen\$(n, 8)) AND isPalin(basen\$(n, 9)) THEN
PRINT n, basen\$(n, 6); " "; basen\$(n, 8); " "; basen\$(n, 9)
END IF
NEXT

FUNCTION basen\$ (x, n)
s\$ = ""
x2 = x
WHILE x2 > 0
d = x2 MOD n: x2 = x2 \ n

s\$ = LTRIM\$(MID\$("0123456789abcdef", d + 1, 1)) + s\$
WEND
basen\$ = s\$
END FUNCTION

FUNCTION isPalin (s\$)
good = 1

FOR i = 1 TO LEN(s\$) / 2
IF MID\$(s\$, i, 1) <> MID\$(s\$, LEN(s\$) + 1 - i, 1) THEN good = 0: EXIT FOR
NEXT
isPalin = good
END FUNCTION

 Posted by Charlie on 2014-04-06 20:50:04

 Search: Search body:
Forums (0)