cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A340559 Numbers that are palindromic in base 2 and base 16.

This page as a plain text file.
%I A340559 #28 Jan 22 2021 22:41:53
%S A340559 0,1,3,5,7,9,15,17,51,85,119,153,255,257,273,771,819,1285,1317,1365,
%T A340559 1397,1799,1831,1879,1911,2313,2409,2457,2553,3855,3951,3999,4095,
%U A340559 4097,4369,12291,13107,20485,21029,21845,22389,28679,29223,30039,30583,36873,38505
%N A340559 Numbers that are palindromic in base 2 and base 16.
%H A340559 Chai Wah Wu, <a href="/A340559/b340559.txt">Table of n, a(n) for n = 1..10000</a>
%t A340559 Select[Range[0, 10^5], PalindromeQ @ IntegerDigits[#, 2] && PalindromeQ @ IntegerDigits[#, 16]  &] (* _Amiram Eldar_, Jan 11 2021 *)
%o A340559 (Python)
%o A340559 def palindrome(x):
%o A340559     res = str(x) == str(x)[::-1]
%o A340559     return res
%o A340559 def dec_to_bin(x):
%o A340559     return int(bin(x)[2:])
%o A340559 def dec_to_hex(x):
%o A340559     return (hex(x)[2:])
%o A340559 for x in range (1,10000):
%o A340559     if palindrome(dec_to_hex(x)) & palindrome(dec_to_bin(x)) == True:
%o A340559           print(x)
%o A340559 (BASIC:- MM Basic, a modern QBASIC variant, https://www.mmbasic.com/)
%o A340559 Function reverse(in_string$) As string
%o A340559   Local r$
%o A340559   Local i
%o A340559   For i = Len(in_string$) To 1 Step -1
%o A340559       b$=Mid$(in_string$,i,1)
%o A340559       r$=r$+b$
%o A340559   Next i
%o A340559   reverse=r$
%o A340559 End Function
%o A340559 For i = 1 To 10000
%o A340559   If Bin$(i) = reverse(Bin$(i)) Then
%o A340559       If Hex$(i) = reverse(Hex$(i)) Then
%o A340559           Print i,Bin$(i), Hex$(i)
%o A340559       EndIf
%o A340559   EndIf
%o A340559 Next i
%o A340559 (PARI) ispal(m, b) = my(d=digits(m, b)); d == Vecrev(d);
%o A340559 isok(m) = ispal(m, 2) && ispal(m, 16); \\ _Michel Marcus_, Jan 20 2021
%Y A340559 Intersection of A006995 and A029730.
%Y A340559 Cf. A029731, A007632.
%K A340559 nonn,base
%O A340559 1,3
%A A340559 _Glen Gilchrist_, Jan 11 2021