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.

Original entry on oeis.org

0, 1, 3, 5, 7, 9, 15, 17, 51, 85, 119, 153, 255, 257, 273, 771, 819, 1285, 1317, 1365, 1397, 1799, 1831, 1879, 1911, 2313, 2409, 2457, 2553, 3855, 3951, 3999, 4095, 4097, 4369, 12291, 13107, 20485, 21029, 21845, 22389, 28679, 29223, 30039, 30583, 36873, 38505
Offset: 1

Views

Author

Glen Gilchrist, Jan 11 2021

Keywords

Crossrefs

Intersection of A006995 and A029730.

Programs

  • Mathematica
    Select[Range[0, 10^5], PalindromeQ @ IntegerDigits[#, 2] && PalindromeQ @ IntegerDigits[#, 16]  &] (* Amiram Eldar, Jan 11 2021 *)
  • 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
  • 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