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.

Showing 1-10 of 13 results. Next

A178226 Characteristic function of A154809 (numbers that are not binary palindromes).

Original entry on oeis.org

0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1
Offset: 0

Views

Author

Jeremy Gardiner, May 23 2010

Keywords

Comments

a(n)=1 if n is in A154809, a(n)=0 otherwise.
Identical to parity of A086757 (Smallest prime p such that n is a palindrome in base p representation)

Crossrefs

Programs

  • Mathematica
    Table[If[IntegerDigits[n,2]==Reverse[IntegerDigits[n,2]],0,1],{n,0,120}] (* Harvey P. Dale, Aug 07 2023 *)
  • PARI
    A178226(n) = (n!=subst(Polrev(binary(n)),x,2)); \\ Antti Karttunen, Dec 15 2017

Formula

a(n) = 1 - A178225(n). - Antti Karttunen, Dec 15 2017

A175392 a(n) is the smallest positive integer that, when written in binary, occurs in binary A154809(n) but not in binary A030101(A154809(n)).

Original entry on oeis.org

2, 2, 2, 2, 10, 11, 2, 6, 2, 2, 18, 19, 4, 11, 11, 2, 6, 6, 2, 6, 2, 2, 34, 35, 18, 18, 19, 19, 4, 10, 42, 11, 4, 11, 11, 2, 6, 6, 4, 6, 22, 23, 2, 6, 6, 14, 2, 6, 2, 2, 66, 67, 34, 34, 35, 35, 8, 18, 11, 19, 13, 19, 19, 4, 10, 10, 10, 4, 11, 11, 4, 11, 10, 91
Offset: 1

Views

Author

Leroy Quet, Apr 28 2010

Keywords

Comments

A154809(n) is the n-th positive integer that is not a palindrome when written in binary.
A030101(n) is the decimal value of the digits of binary n written in backwards order.
No substring in binary n is absent from binary A030101(n) if n is a palindrome when written in binary.
It is immaterial if the leading 0's are included as part of A030101(A154809(n)) when checking if a particular substring is part of it, because the binary representations of all substrings begin with 1.

Examples

			20 in binary is 10100. A030101(20) = 5, which is 00101 = 101 in binary. The positive integers that occur as substrings of 10100 when written in binary are 1 (1 in binary), 2 (10 in binary), 4 (100 in binary), 5 (101 in binary), 10 (1010 in binary), and 20 (10100 in binary). The binary substring with the largest decimal value not present in (00)101 is 100, which is 4 in decimal. So a(20) = 4.
		

Crossrefs

Programs

  • PARI
    in(abc, b) = my (m=2^#binary(b)); while (abc >= b, if (abc%m==b, return (1), abc\=2)); return (0)
    for (v=1, 91, my (w=fromdigits(Vecrev(binary(v)),2)); if (v!=w, for (k=1, oo, if (in(v,k) && !in(w,k), print1 (k ", "); break)))) \\ Rémy Sigrist, Nov 08 2018

Extensions

More terms from Rémy Sigrist, Nov 08 2018

A006995 Binary palindromes: numbers whose binary expansion is palindromic.

Original entry on oeis.org

0, 1, 3, 5, 7, 9, 15, 17, 21, 27, 31, 33, 45, 51, 63, 65, 73, 85, 93, 99, 107, 119, 127, 129, 153, 165, 189, 195, 219, 231, 255, 257, 273, 297, 313, 325, 341, 365, 381, 387, 403, 427, 443, 455, 471, 495, 511, 513, 561, 585, 633, 645, 693, 717, 765, 771, 819, 843
Offset: 1

Views

Author

Keywords

Comments

If b > 1 is a binary palindrome then both (2^(m+1) + 1)*b and 2^(m+1) + 2^m - b are also, where m = floor(log_2(b)). - Hieronymus Fischer, Feb 18 2012
Floor and ceiling: If d > 0 is any natural number, then A206913(d) is the greatest binary palindrome <= d and A206914(d) is the least binary palindrome >= d. - Hieronymus Fischer, Feb 18 2012
The greatest binary palindrome <= the n-th non-binary-palindrome is that binary palindrome with number A154809(n)-n+1. The corresponding formula identity is: A206913(A154809(n)) = A006995(A154809(n)-n+1). - Hieronymus Fischer, Mar 18 2012
From Hieronymus Fischer, Jan 23 2013: (Start)
The number of binary digits of a(n) is A070939(a(n)) = 1 + floor(log_2(n)) + floor(log_2(n/3)), for n > 1.
Also: A070939(a(n)) = A070939(n) + A070939(floor(n/3)) - 1, for n <> 2. (End)
Rajasekaran, Shallit, & Smith show that this is an additive basis of order 4. - Charles R Greathouse IV, Nov 06 2018

Examples

			a(3) = 3, since 3 = 11_2 is the 3rd symmetric binary number;
a(6) = 9, since 9 = 1001_2 is the 6th symmetric binary number.
		

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

See A057148 for the binary representations.
Cf. A178225, A005408, A164126, A154809 (complement).
Even numbers that are not the sum of two terms: A241491, A261678, A262556.
Cf. A145799.
Primes: A016041 and A117697.
Cf. A000051 (a subsequence).

Programs

  • Haskell
    a006995 n = a006995_list !! (n-1)
    a006995_list = 0 : filter ((== 1) . a178225) a005408_list
    -- Reinhard Zumkeller, Oct 21 2011
    
  • Magma
    [n: n in [0..850] | Intseq(n,2) eq Reverse(Intseq(n,2))];  // Bruno Berselli, Aug 29 2011
    
  • Maple
    dmax:= 15; # to get all terms with at most dmax binary digits
    revdigs:= proc(n)
      local L, Ln, i;
      L:= convert(n,base,2);
      Ln:= nops(L);
      add(L[i]*2^(Ln-i),i=1..Ln);
    end proc;
    A:= {0,1}:
    for d from 2 to dmax do
      if d::even then
        A:= A union {seq(2^(d/2)*x + revdigs(x),x=2^(d/2-1)..2^(d/2)-1)}
      else
        m:= (d-1)/2;
        B:={seq(2^(m+1)*x + revdigs(x),x=2^(m-1)..2^m-1)};
        A:= A union B union map(`+`,B,2^m)
      fi
    od:
    A;  # Robert Israel, Aug 17 2014
  • Mathematica
    palQ[n_Integer, base_Integer] := Module[{idn=IntegerDigits[n, base]}, idn==Reverse[idn]]; Select[Range[1000], palQ[ #, 2]&]
    Select[ Range[0, 1000], # == IntegerReverse[#, 2] &] (* Robert G. Wilson v, Feb 24 2018 *)
    Select[Range[0, 1000], PalindromeQ[IntegerDigits[#, 2]]&] (* Jean-François Alcover, Mar 01 2018 *)
  • PARI
    for(n=0,999,n-subst(Polrev(binary(n)),x,2)||print1(n,",")) \\ Thomas Buchholz, Aug 16 2014
    
  • PARI
    for(n=0,10^3, my(d=digits(n,2)); if(d==Vecrev(d), print1(n,", "))); \\ Joerg Arndt, Aug 17 2014
    
  • PARI
    is_A006995(n)=Vecrev(n=binary(n))==n \\ M. F. Hasler, Feb 23 2018
    
  • PARI
    A006995(n,m=logint(n,2),c=1<<(m-1),a,d)={if(n>=3*c,a=n-3*c;d=2*c^2,a=n-2*c;n%2*c+d=c^2)+sum(k=1,m-2^(n<3*c),if(bittest(a,m-1-k),1<>k))+(n>2)} \\ Based on Fischer's smalltalk program. - M. F. Hasler, Feb 23 2018
    
  • Python
    from itertools import count, islice, product
    def bin_pals(): # generator of binary palindromes in base 10
        yield from [0, 1]
        digits, midrange = 2, [[""], ["0", "1"]]
        for digits in count(2):
            for p in product("01", repeat=digits//2-1):
                left = "1"+"".join(p)
                for middle in midrange[digits%2]:
                    yield int(left + middle + left[::-1], 2)
    print(list(islice(bin_pals(), 58))) # Michael S. Branicky, Jan 09 2023
    
  • Python
    def A006995(n):
        if n == 1: return 0
        a = 1<<(l:=n.bit_length()-2)
        m = a|(n&a-1)
        return (m<Chai Wah Wu, Jun 10 2024
  • Sage
    def palgenbase2(): # generator of palindromes in base 2
        yield 0
        x, n, n2 = 1, 1, 2
        while True:
            for y in range(n,n2):
                s = format(y,'b')
                yield int(s+s[-2::-1],2)
            for y in range(n,n2):
                s = format(y,'b')
                yield int(s+s[::-1],2)
            x += 1
            n *= 2
            n2 *= 2 # Chai Wah Wu, Jan 07 2015
    
  • Sage
    [n for n in (0..843) if Word(n.digits(2)).is_palindrome()] # Peter Luschny, Sep 13 2018
    
  • Smalltalk
    A006995
    "Answer the n-th binary palindrome
    (nonrecursive implementation)"
    | m n a b c d k2 |
    n := self.
    n = 1 ifTrue: [^0].
    n = 2 ifTrue: [^1].
    m := n integerFloorLog: 2.
    c := 2 raisedToInteger: m - 1.
    n >= (3 * c)
      ifTrue:
       [a := n - (3 * c).
       d := 2 * c * c.
       b := d + 1.
       k2 := 1.
       1 to: m - 1
        do:
         [:k |
         k2 := 2 * k2.
         b := b + (a * k2 // c \\ 2 * (k2 + (d // k2)))]]
      ifFalse:
       [a := n - (2 * c).
       d := c * c.
       b := d + 1 + (n \\ 2 * c).
       k2 := 1.
       1 to: m - 2
        do:
         [:k |
         k2 := 2 * k2.
         b := b + (a * k2 // c \\ 2 * (k2 + (d // k2)))]].
    ^b // by Hieronymus Fischer, Feb 15 2013
    

Formula

A178225(a(n)) = 1; union of A048700 and A048701. - Reinhard Zumkeller, Oct 21 2011
From Hieronymus Fischer, Dec 31 2008, Jan 10 2012, Feb 18 2012: (Start)
Written as a decimal, a(10^n) has 2*n digits. For n > 1, the decimal expansion of a(10^n) starts with 22..., 23... or 24...:
a(1000) = 249903,
a(10^4) = 24183069,
a(10^5) = 2258634081,
a(10^6) = 249410097687,
a(10^7) = 24350854001805,
a(10^8) = 2229543293296319,
a(10^9) = 248640535848971067,
a(10^10)= 24502928886295666773.
Inequality: (2/9)*n^2 < a(n) < (1/4)*(n+1)^2, if n > 1.
lim sup_{n -> oo} a(n)/n^2 = 1/4, lim inf_{n -> oo} a(n)/n^2 = 2/9.
For n >= 2, a(2^n-1) = 2^(2n-2) - 1; a(2^n) = 2^(2n-2) + 1;
a(2^n+1) = 2^(2n-2) + 2^(n-1) + 1; a(2^n + 2^(n-1)) = 2^(2n-1) + 1.
Recursion for n > 2: a(n) = 2^(2k-q) + 1 + 2^p*a(m), where k = floor(log_2(n-1)), and p, q and m are determined as follows:
Case 1: If n = 2^(k+1), then p = 0, q = 0, m = 1;
Case 2: If 2^k < n < 2^k+2^(k-1), then p = k-floor(log_2(i))-1 with i = n-2^k, q = 2, m = 2^floor(log_2(i)) + i;
Case 3: If n = 2^k + 2^(k-1), then p = 0, q = 1, m = 1;
Case 4: If 2^k + 2^(k-1) < n < 2^(k+1), then p = k-floor(log_2(j))-1 with j = n-2^k-2^(k-1), q = 1, m = 2*2^floor(log_2(j))+j.
Non-recursive formula:
Let n >= 3, m = floor(log_2(n)), p = floor((3*2^(m-1)-1)/n), then
a(n) = 2^(2*m-1-p) + 1 + p*(1-(-1)^n)*2^(m-1-p) + sum_{k=1 .. m-1-p} (floor((n-(3-p)*2^(m-1))/2^(m-1-k)) mod 2)*(2^k+2^(2*m-1-p-k)). [Typo at the last exponent of the third sum term eliminated by the author, Sep 05 2018]
a(n) = 2^(2*m-2) + 1 + 2*floor((n-2^m)/2^(m-1)) + 2^(m-1)*floor((1/2)*min(n+1-2^m,2^(m-1)+1)) + 3*2^(m-1)*floor((1/2)*max(n+1-3*2^(m-1),0)) + 3*sum_{j=2 .. m-1} floor((n+2^(j-1)-2^m)/2^j)*2^(m-j). [Seems correct for n > 3. - The Editors]
Inversion formula: The index of any binary palindrome b = a(n) > 0 is n = palindromicIndex(b) = ((5-(-1)^m)/2 + Sum_{k=1..[m/2]} ([b/2^k] mod 2)/2^k)*2^[m/2], where [.] = floor(.) and m = [log_2(b)].
(End)
G.f.: g(x) = x^2 + 3x^3 + sum_{j=1..oo}( 3*2^j*(1-x^floor((j+1)/2))/(1-x)*x^((1/2)-floor((j+1)/2)) + f_j(x) - f_j(1/x))*x^(2*2^floor(j/2)+3*2^floor((j-1)/2)-(1/2)), where the f_j(x) are defined as follows:
f_1(x) = x^(1/2), and for j > 1,
f_j(x) = x^(1/2)*sum_{i=0..2^floor((j-1)/2)-1}((3+(1/2)*sum_{k=1..floor((j-1)/2)}(1-(-1)^floor(2i/2^k))*b(j,k))*x^i), where b(j,k) = 2^(floor((j-1)/2)-k)*((3+(-1)^j)*2^(2*k+1)+4) for k > 1, and b(j,1) = (2+(-1)^j)*2^(floor((j-1)/2)+1). - Hieronymus Fischer, Apr 04 2012
A044051(n) = (a(n)+1)/2 for n > 0. - Reinhard Zumkeller, Apr 20 2015
A145799(a(n)) = a(n). - Reinhard Zumkeller, Sep 24 2015
Sum_{n>=2} 1/a(n) = A244162. - Amiram Eldar, Oct 17 2020

Extensions

Edited and extended by Hieronymus Fischer, Feb 21 2012
Edited by M. F. Hasler, Feb 23 2018

A178225 Characteristic function of A006995 (binary palindromes).

Original entry on oeis.org

1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0
Offset: 0

Views

Author

Jeremy Gardiner, May 23 2010

Keywords

Comments

a(n)=1 if n is in A006995, a(n)=0 otherwise.
For n<43, identical to parity of A175096.
Comment by Franklin T. Adams-Watters: (Start)
Any permutation of the runs of n gives another such permutation when reversed. This pairs up all non-palindromic permutations of the runs of n. Thus the parity of A175096(n) is the parity of the number of palindromic run-permutations of n. For small n, this is 1 when n is a binary palindrome, and 0 otherwise.
The first exception is 43, binary 101011, which has a nontrivial palindromic run-permutation 45, binary 101101. Another kind of exception occurs first for n = 365, binary 101101101, which is a palindrome, but has another palindromic run-permutation 427, binary 110101011. (End)
Given an index n such that a(n)=1, then the following A164126(A206915(n))-1 terms will be 0. n'=A164126(A206915(n)) is the next term with a(n')=1. Therefore, if we subtract 1 from each term of A164126, we get the sequence of run lengths of 0's. - Hieronymus Fischer, Feb 19 2012.
Given an index n such that a(n)=0, then p=A206913(n) is the greatest index pA206914(n) is the least index q>n such that a(q)=1, which implies a(k)=0 for all k with n<=kHieronymus Fischer, Feb 19 2012.
Binary palindromes are distributed symmetrically with respect to threefold multiples of powers of 2. This becomes obvious by the generating function g(x) below. Example for the resulting factors of x^(3*2^5)=x^96: the factors are x^q and x^(-q) for q=3,11,23,31. Thus, the palindromes are 96+3, 96-3, 96+11, 96-11, 96+23, 96-23, 96+31, 96-31. The respective number of palindromes with this property is 2^(floor(m/2)), where m is the exponent of the corresponding power of 2. - Hieronymus Fischer, Apr 04 2012

Examples

			a(3)=1, since 3 is binary palindromic;
a(4)=0, since 4 is not palindromic.
		

Crossrefs

Cf. A136522. See A206915 for the partial sums.

Programs

  • Haskell
    a178225 n = fromEnum $ n == a030101 n  -- Reinhard Zumkeller, Oct 21 2011
    
  • Mathematica
    A178225[n_]:=Boole[PalindromeQ[IntegerDigits[n,2]]];
    Array[A178225,100,0] (* Paolo Xausa, Oct 15 2023 *)
  • PARI
    a(n) = my(b=binary(n)); b == Vecrev(b); \\ Michel Marcus, Feb 13 2019
    
  • Python
    a187225 = lambda n: int(bin(n)[2:] == bin(n)[:1:-1]) # David Radcliffe, May 05 2023

Formula

a(A006995(n)) = 1; a(A154809(n)) = 0. - Reinhard Zumkeller, Oct 21 2011
a(n) = if A030101(n) = n then 1, otherwise 0. - Reinhard Zumkeller, Jan 17 2012
a(n) = 1 - (A206916(n) - A206915(n)). - Hieronymus Fischer, Feb 18 2012
G.f.: g(x) = 1 + x + x^3 + Sum{j>=1} x^(3*2^j)*(f_j(x)+f_j(1/x)), where the f_j(x) are defined as follows:
f_1(x)=x, and for j > 1,
f_j(x) = x^3*Product_{k=1..floor((j-1)/2)} (1+x^b(j,k)), where b(j,k) = 2^(floor((j-1)/2)-k)*((3+(-1)^j)*2^(2*k+1)+4) for k > 1, and b(j,1) = (2+(-1)^j)*2^(floor((j-1)/2)+1). The first explicit terms of this g.f. are
g(x) = 1 + x + x^3 + (f_1(x) + f_1(1/x))*x^6 + (f_2(x) + f_2(1/x))*x^12 + (f_3(x)+f_3(1/x))*x^24 + (f_4(x) + f_4(1/x))*x^48 + (f_5(x) + f_5(1/x))*x^96 + ... = 1 + x + x^3 + (x+1/x)*x^6 + (x^3+1/x^3)*x^12 + (x^3*(1+x^4) + (1+1/x^4)/x^3)*x^24 + (x^3*(1+x^12) + (1+1/x^12)/x^3)*x^48 + (x^3*(1+x^8)(1+x^20) + (1+1/x^20)(1+1/x^8)/x^3)*x^96 + ... - Hieronymus Fischer, Apr 02 2012

A206923 Number of bisections of the n-th binary palindrome bit pattern until the result is not palindromic.

Original entry on oeis.org

1, 1, 2, 1, 3, 1, 3, 1, 2, 1, 4, 1, 2, 1, 4, 1, 2, 1, 1, 1, 1, 1, 4, 1, 2, 1, 1, 1, 1, 1, 4, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 5, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 5, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1
Offset: 1

Views

Author

Hieronymus Fischer, Mar 12 2012

Keywords

Comments

Let k=1, p(1)=A006995(n) and m(1)=number of bits in p(1); if p(k) is a binary palindrome > 1 then iterate k=k+1, m(k)=floor((m(k-1)+1)/2), p(k)=leftmost m(k) bits of p(k-1); else set a(n)=k endif.

Examples

			a(1)=a(2)=1, since A006995(1)=0 and A006995(2)=1;
a(5)=3, since A006995(5)=7=111_2 and so the iteration is 11==>11==>1;
a(9)=2, since A006995(9)=21=10101_2 and so the iteration is 10101==>101;
a(13)=2, since A006995(13)=45=101101_2 and so the iteration is 101101==>101;
a(15)=4, since A006995(15)=63=111111_2 and so the iteration is 111111==>111==>11==>1;
a(37)=3, since A006995(37)=341=101010101_2 and so the iteration is 101010101==>10101==>101;
		

Crossrefs

Programs

  • C
    /* quasi-C program fragment, omitting formal details, n>1 */
    p=n;
    p1=n+1;
    k=0;
    while (A178225(p)==1) && (p != p1)
    {
      p1=p;
      k++;
      m=int(log(p)/log(2));
      p=int(p/2^int((m+1)/2));
    }
    return k;

Formula

Recursion: define f(x)=floor(A006995(x)/2^floor(floor(log_2(A006995(x))+1)/2)), for x=1,2,3,...
Case 1: a(n)=1+a(A206915(f(n))), if f(n) is a binary palindrome;
Case 2: a(n)=1, else.
Formally: a(n)=if (A178225(f(n))==1) then a(A206915(f(n)))+1 else 1.

A145799 a(n) = the largest integer that is an (odd) palindrome when represented in binary and that occurs in the binary representation of n.

Original entry on oeis.org

1, 1, 3, 1, 5, 3, 7, 1, 9, 5, 5, 3, 5, 7, 15, 1, 17, 9, 9, 5, 21, 5, 7, 3, 9, 5, 27, 7, 7, 15, 31, 1, 33, 17, 17, 9, 9, 9, 9, 5, 9, 21, 21, 5, 45, 7, 15, 3, 17, 9, 51, 5, 21, 27, 27, 7, 9, 7, 27, 15, 15, 31, 63, 1, 65, 33, 33, 17, 17, 17, 17, 9, 73, 9, 9, 9, 9, 9, 15, 5, 17, 9, 9, 21, 85, 21, 21
Offset: 1

Views

Author

Leroy Quet, Oct 19 2008

Keywords

Comments

The binary expansion of a(n) is the largest (odd) palindrome that appears as a substring of the binary expansion of n. Nonzero binary palindromes are necessarily odd (see A006995).
For n = 2^k, a(n) = 1 is the largest binary palindrome in the binary representation of n.
a(2^k*A006995(n)) = A006995(n). - Ray Chandler, Oct 26 2008
a(m) = m iff m is a palindrome: a(A006995(n)) = A006995(n), a(A154809(n)) < A154809(n). - Reinhard Zumkeller, Sep 24 2015

Examples

			20 in binary is 10100. The largest binary palindrome included in this binary representation is 101, which is 5 in decimal. So a(20) = 5.
		

Crossrefs

Programs

  • Haskell
    a145799 = maximum . map (foldr (\b v -> 2 * v + b) 0) .
                        filter (\bs -> bs == reverse bs && head bs == 1) .
                        substr . bin where
       substr [] = []
       substr us'@(_:us) = sub us' ++ substr us where
          sub [] = []; sub (v:vs) = [v] : [v : ws | ws <- sub vs ]
       bin 0 = []; bin n = b : bin n' where (n', b) = divMod n 2
    -- Reinhard Zumkeller, Sep 24 2015
  • Mathematica
    Block[{nn = 87, s}, s = Reverse@ Select[IntegerDigits[#, 2] & /@ Range[2^Log2@ nn], PalindromeQ]; Table[With[{d = IntegerDigits[n, 2]}, FromDigits[#, 2] &@ SelectFirst[s, SequenceCount[d, #] > 0 &]], {n, nn}]] (* Michael De Vlieger, Sep 23 2017 *)

Extensions

Extended by Ray Chandler, Oct 26 2008

A164861 Odd positive integers that are not palindromes when written in binary.

Original entry on oeis.org

11, 13, 19, 23, 25, 29, 35, 37, 39, 41, 43, 47, 49, 53, 55, 57, 59, 61, 67, 69, 71, 75, 77, 79, 81, 83, 87, 89, 91, 95, 97, 101, 103, 105, 109, 111, 113, 115, 117, 121, 123, 125, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 155, 157, 159, 161, 163, 167
Offset: 1

Views

Author

Leroy Quet, Aug 28 2009

Keywords

Comments

These are the odd members of A154809.

Crossrefs

Cf. A154809.

Programs

  • Haskell
    a164861 n = a164861_list !! (n-1)
    a164861_list = filter ((== 0) . a178225) a005408_list
    -- Reinhard Zumkeller, Oct 21 2011
  • Mathematica
    npbQ[n_]:=Module[{idn2=IntegerDigits[n,2]},idn2!=Reverse[idn2]]; Select[ Range[1,201,2],npbQ] (* Harvey P. Dale, May 17 2012 *)

Formula

A178225(a(n)) * (1 - A000035(a(n))) = 0. [Reinhard Zumkeller, Oct 21 2011]

Extensions

Extended by Ray Chandler, Mar 14 2010

A272670 Numbers whose binary expansion is not palindromic but which when reversed and leading zeros omitted, does form a palindrome.

Original entry on oeis.org

2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 24, 28, 30, 32, 34, 36, 40, 42, 48, 54, 56, 60, 62, 64, 66, 68, 72, 80, 84, 90, 96, 102, 108, 112, 120, 124, 126, 128, 130, 132, 136, 144, 146, 160, 168, 170, 180, 186, 192, 198, 204, 214, 216, 224, 238, 240, 248, 252, 254
Offset: 1

Views

Author

N. J. A. Sloane, May 19 2016

Keywords

Comments

Decimal interpretation of A273245. Twice A057890.

Crossrefs

Cf. A006995, A057890, A273245, A273329, subsequence of A154809.

Programs

  • Maple
    isPal := proc(L::list)
        local i;
        for i from 1 to nops(L)/2 do
            if op(i,L) <> op(-i,L) then
                return false;
            end if;
        end do:
        true ;
    end proc:
    isA272670 := proc(n)
        local bdgs ;
        bdgs := convert(n,base,2) ;
        if isPal(bdgs) then
            return false;
        else
            A000265(n) ;
            bdgs := convert(%,base,2) ;
            isPal(bdgs) ;
        end if;
    end proc:
    for n from 1 to 500 do
        if isA272670(n) then
            printf("%d,",n) ;
        end if;
    end do: # R. J. Mathar, May 20 2016
  • Python
    A272670_list = [n for n in range(1,10**4) if bin(n)[2:] != bin(n)[:1:-1] and bin(n)[2:].rstrip('0') == bin(n)[:1:-1].lstrip('0')] # Chai Wah Wu, May 21 2016

A154810 Nonpalindromic numbers with binary digits only.

Original entry on oeis.org

10, 100, 110, 1000, 1010, 1011, 1100, 1101, 1110, 10000, 10010, 10011, 10100, 10110, 10111, 11000, 11001, 11010, 11100, 11101, 11110, 100000, 100010, 100011, 100100, 100101, 100110, 100111, 101000, 101001, 101010, 101011, 101100, 101110, 101111
Offset: 1

Views

Author

Omar E. Pol, Jan 24 2009

Keywords

Comments

A154809 written in base 2.

Crossrefs

Programs

  • Mathematica
    Map[FromDigits, Select[IntegerDigits[Range[50], 2], !PalindromeQ[#] &]] (* Paolo Xausa, Jul 24 2024 *)
  • Python
    def A154810(n):
        def f(x): return n+(x>>(l:=x.bit_length())-(k:=l+1>>1))-(int(bin(x)[k+1:1:-1],2)>(x&(1<Chai Wah Wu, Jul 24 2024

Formula

a(n) = A007088(A154809(n)). - Michel Marcus, Jul 24 2024

Extensions

Extended by Ray Chandler, Mar 14 2010

A206921 Rank of the n-th binary palindrome. The minimal number of iterations A206915(A206915(...A206915(A006995(n))...)) such that the result is not a binary palindrome, a(3)=1.

Original entry on oeis.org

2, 1, 1, 1, 2, 1, 3, 1, 2, 1, 1, 1, 1, 1, 4, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1
Offset: 1

Views

Author

Hieronymus Fischer, Mar 12 2012

Keywords

Comments

The number of iterations such that A006995(n) = A006995(A006995(A006995(...(A206922(n))...))) [For n<>3].

Examples

			a(1)=2, since A006995(1)=0=A006995(A006995(2)) [==> 2 iterations; 2 is not a binary palindrome];
a(3)=1 by definition;
a(4)=1, since A006995(4)=5=A006995(4) [==> 1 iteration; 4 is not a binary palindrome];
a(7)=3, since A006995(7)=15=A006995(A006995(A006995(4))) [==> 3 iterations; 4 is not a binary palindrome];
		

Crossrefs

Programs

Formula

a(n)=k, where k can be determined by the following iteration: set k=0, p(0)=A006995(n). Repeat while A178225(p(k))==1, set k=k+1, p(k)=A206915(p(k-1)) end repeat [for n<>3].
Recursion for n<>3:
Case 1: a(n)=1, if n is not a binary palindrome;
Case 2: a(n)=a(A206915(n))+1, else.
Formally: a(n)=if (A178225(n)==0) then 1 else a(A206915(n))+1
Showing 1-10 of 13 results. Next