OFFSET
1,3
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..10000
MATHEMATICA
Select[Range[0, 10^5], PalindromeQ @ IntegerDigits[#, 2] && PalindromeQ @ IntegerDigits[#, 16] &] (* Amiram Eldar, Jan 11 2021 *)
PROG
(Python)
def palindrome(x):
res = str(x) == str(x)[::-1]
return res
def dec_to_bin(x):
return int(bin(x)[2:])
def dec_to_hex(x):
return (hex(x)[2:])
for x in range (1, 10000):
if palindrome(dec_to_hex(x)) & palindrome(dec_to_bin(x)) == True:
print(x)
(BASIC:- MM Basic, a modern QBASIC variant, https://www.mmbasic.com/)
Function reverse(in_string$) As string
Local r$
Local i
For i = Len(in_string$) To 1 Step -1
b$=Mid$(in_string$, i, 1)
r$=r$+b$
Next i
reverse=r$
End Function
For i = 1 To 10000
If Bin$(i) = reverse(Bin$(i)) Then
If Hex$(i) = reverse(Hex$(i)) Then
Print i, Bin$(i), Hex$(i)
EndIf
EndIf
Next i
(PARI) ispal(m, b) = my(d=digits(m, b)); d == Vecrev(d);
isok(m) = ispal(m, 2) && ispal(m, 16); \\ Michel Marcus, Jan 20 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Glen Gilchrist, Jan 11 2021
STATUS
approved