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-4 of 4 results.

A035928 Numbers n such that BCR(n) = n, where BCR = binary-complement-and-reverse = take one's complement then reverse bit order.

Original entry on oeis.org

2, 10, 12, 38, 42, 52, 56, 142, 150, 170, 178, 204, 212, 232, 240, 542, 558, 598, 614, 666, 682, 722, 738, 796, 812, 852, 868, 920, 936, 976, 992, 2110, 2142, 2222, 2254, 2358, 2390, 2470, 2502, 2618, 2650, 2730, 2762, 2866, 2898, 2978, 3010, 3132, 3164, 3244
Offset: 1

Views

Author

Keywords

Comments

Numbers n such that A036044(n) = n.
Also: numbers such that n+BR(n) is in A000225={2^k-1} (with BR = binary reversed). - M. F. Hasler, Dec 17 2007
Also called "antipalindromes". - Jeffrey Shallit, Feb 04 2022

Examples

			38 is such a number because 38=100110; complement to get 011001, then reverse bit order to get 100110.
		

Crossrefs

Cf. A061855.
Intersection of A195064 and A195066; cf. A195063, A195065.

Programs

  • Haskell
    a035928 n = a035928_list !! (n-1)
    a035928_list = filter (\x -> a036044 x == x) [0,2..]
    -- Reinhard Zumkeller, Sep 16 2011
    
  • Maple
    [seq(ReflectBinSeq(j,(floor_log_2(j)+1)),j=1..256)];
    ReflectBinSeq := (x,n) -> (((2^n)*x)+binrevcompl(x));
    binrevcompl := proc(nn) local n,z; n := nn; z := 0; while(n <> 0) do z := 2*z + ((n+1) mod 2); n := floor(n/2); od; RETURN(z); end;
    floor_log_2 := proc(n) local nn,i: nn := n; for i from -1 to n do if(0 = nn) then RETURN(i); fi: nn := floor(nn/2); od: end; # Computes essentially the same as floor(log[2](n))
    # alternative Maple program:
    q:= n-> (l-> is(n=add((1-l[-i])*2^(i-1), i=1..nops(l))))(Bits[Split](n)):
    select(q, [$1..3333])[];  # Alois P. Heinz, Feb 10 2021
  • Mathematica
    bcrQ[n_]:=Module[{idn2=IntegerDigits[n,2]},Reverse[idn2/.{1->0,0->1}] == idn2]; Select[Range[3200],bcrQ] (* Harvey P. Dale, May 24 2012 *)
  • PARI
    for(n=1,1000,l=length(binary(n)); b=binary(n); if(sum(i=1,l,abs(component(b,i)-component(b,l+1-i)))==l,print1(n,",")))
    
  • PARI
    for(i=1,999,if(Set(vecextract(t=binary(i),"-1..1")+t)==[1],print1(i","))) \\ M. F. Hasler, Dec 17 2007
    
  • PARI
    a(n) = my (b=binary(n)); (n+1)*2^#b-fromdigits(Vecrev(b),2)-1 \\ Rémy Sigrist, Mar 15 2021
    
  • Python
    def comp(s): z, o = ord('0'), ord('1'); return s.translate({z:o, o:z})
    def BCR(n): return int(comp(bin(n)[2:])[::-1], 2)
    def aupto(limit): return [m for m in range(limit+1) if BCR(m) == m]
    print(aupto(3244)) # Michael S. Branicky, Feb 10 2021
    
  • Python
    from itertools import count, islice
    def A035928_gen(startvalue=1): # generator of terms >= startvalue
        return filter(lambda n:n==int(format(~n&(1<<(m:=n.bit_length()))-1,'0'+str(m)+'b')[::-1],2),count(max(startvalue,1)))
    A035928_list = list(islice(A035928_gen(),30)) # Chai Wah Wu, Jun 30 2022

Formula

If offset were 0, a(2n+1) - a(2n) = 2^floor(log_2(n)+1).
a(n) = n * A062383(n) + A036044(n). - Rémy Sigrist, Jun 11 2022

Extensions

More terms from Erich Friedman

A036044 BCR(n): write in binary, complement, reverse.

Original entry on oeis.org

1, 0, 2, 0, 6, 2, 4, 0, 14, 6, 10, 2, 12, 4, 8, 0, 30, 14, 22, 6, 26, 10, 18, 2, 28, 12, 20, 4, 24, 8, 16, 0, 62, 30, 46, 14, 54, 22, 38, 6, 58, 26, 42, 10, 50, 18, 34, 2, 60, 28, 44, 12, 52, 20, 36, 4, 56, 24, 40, 8, 48, 16, 32, 0, 126, 62, 94, 30, 110, 46, 78, 14, 118, 54, 86
Offset: 0

Views

Author

Keywords

Comments

a(0) could be considered to be 0 if the binary representation of zero were chosen to be the empty string. - Jason Kimberley, Sep 19 2011
From Bernard Schott, Jun 15 2021: (Start)
Except for a(0) = 1, every term is even.
For each q >= 0, there is one and only one odd number h such that a(n) = 2*q iff n = h*2^m-1 for m >= 1 when q = 0, and for m >= 0 when q >= 1 (see A345401 and some examples below).
a(n) = 0 iff n = 2^m-1 for m >= 1 (Mersenne numbers) (A000225).
a(n) = 2 iff n = 3*2^m-1 for m >= 0 (A153893).
a(n) = 4 iff n = 7*2^m-1 for m >= 0 (A086224).
a(n) = 6 iff n = 5*2^m-1 for m >= 0 (A153894).
a(n) = 8 iff n = 15*2^m-1 for m >= 0 (A196305).
a(n) = 10 iff n = 11*2^m-1 for m >= 0 (A086225).
a(n) = 12 iff n = 13*2^m-1 for m >= 0 (A198274).
For k >= 1, a(n) = 2^k iff n = (2^(k+1)-1)*2^m - 1 for m >= 0.
Explanation for a(n) = 2:
For m >= 0, A153893(m) = 3*2^m-1 -> 1011...11 -> 0100...00 -> 10 -> 2 where 1011...11_2 is 10 followed by m 1's. (End)

Examples

			4 -> 100 -> 011 -> 110 -> 6.
		

Crossrefs

Cf. A035928 (fixed points), A195063, A195064, A195065, A195066.
Indices of terms 0, 2, 4, 6, 8, 10, 12, 14, 18, 22, 26, 30: A000225 \ {0}, A153893, A086224, A153894, A196305, A086225, A198274, A052996\{1,3}, A291557, A198276, A171389, A198275.

Programs

  • Haskell
    import Data.List (unfoldr)
    a036044 0 = 1
    a036044 n = foldl (\v d -> 2 * v + d) 0 (unfoldr bc n) where
       bc 0 = Nothing
       bc x = Just (1 - m, x') where (x',m) = divMod x 2
    -- Reinhard Zumkeller, Sep 16 2011
    
  • Magma
    A036044:=func; // Jason Kimberley, Sep 19 2011
    
  • Maple
    A036044 := proc(n)
        local bcr ;
        if n = 0 then
            return 1;
        end if;
        convert(n,base,2) ;
        bcr := [seq(1-i,i=%)] ;
        add(op(-k,bcr)*2^(k-1),k=1..nops(bcr)) ;
    end proc:
    seq(A036044(n),n=0..200) ; # R. J. Mathar, Nov 06 2017
  • Mathematica
    dtn[ L_ ] := Fold[ 2#1+#2&, 0, L ]; f[ n_ ] := dtn[ Reverse[ 1-IntegerDigits[ n, 2 ] ] ]; Table[ f[ n ], {n, 0, 100} ]
    Table[FromDigits[Reverse[IntegerDigits[n,2]/.{1->0,0->1}],2],{n,0,80}] (* Harvey P. Dale, Mar 08 2015 *)
  • PARI
    a(n)=fromdigits(Vecrev(apply(n->1-n,binary(n))),2) \\ Charles R Greathouse IV, Apr 22 2015
    
  • Python
    def comp(s): z, o = ord('0'), ord('1'); return s.translate({z:o, o:z})
    def BCR(n): return int(comp(bin(n)[2:])[::-1], 2)
    print([BCR(n) for n in range(75)]) # Michael S. Branicky, Jun 14 2021
    
  • Python
    def A036044(n): return -int((s:=bin(n)[-1:1:-1]),2)-1+2**len(s) # Chai Wah Wu, Feb 04 2022

Formula

a(2n) = 2*A059894(n), a(2n+1) = a(2n) - 2^floor(log_2(n)+1). - Ralf Stephan, Aug 21 2003
Conjecture: a(n) = (-1)^A023416(n)*b(n) for n > 0 with a(0) = 1 where b(2^m) = (-1)^m*(2^(m+1) - 2) for m >= 0, b(2n+1) = b(n) for n > 0, b(2n) = b(n) + b(n - 2^f(n)) + b(2n - 2^f(n)) for n > 0 and where f(n) = A007814(n) (see A329369). - Mikhail Kurkov, Dec 13 2024

A195063 Numbers n such that BCR(n) is less than n, where BCR = binary-complement-and-reverse = A036044.

Original entry on oeis.org

6, 14, 22, 26, 28, 30, 46, 50, 54, 58, 60, 62, 78, 86, 90, 94, 98, 102, 106, 108, 110, 114, 116, 118, 120, 122, 124, 126, 158, 166, 174, 182, 186, 190, 194, 198, 202, 206, 210, 214, 218, 220, 222, 226, 228, 230, 234, 236, 238, 242, 244, 246, 248, 250, 252
Offset: 1

Views

Author

Reinhard Zumkeller, Sep 16 2011

Keywords

Comments

A035928(a(n)) < n.

Crossrefs

Complement of A195066; subsequence of A195064; cf. A035928, A195065.

Programs

  • Haskell
    a195063 n = a195063_list !! (n-1)
    a195063_list = filter (\x -> a036044 x < x) [0,2..]

A195065 Numbers n such that BCR(n) is greater than n, where BCR = binary-complement-and-reverse = A036044.

Original entry on oeis.org

0, 4, 8, 16, 18, 20, 24, 32, 34, 36, 40, 44, 48, 64, 66, 68, 70, 72, 74, 76, 80, 82, 84, 88, 92, 96, 100, 104, 112, 128, 130, 132, 134, 136, 138, 140, 144, 146, 148, 152, 154, 156, 160, 162, 164, 168, 172, 176, 180, 184, 188, 192, 196, 200, 208, 216, 224
Offset: 1

Views

Author

Reinhard Zumkeller, Sep 16 2011

Keywords

Comments

A035928(a(n)) > n.

Crossrefs

Complement of A195064; subsequence of A195066.

Programs

  • Haskell
    a195065 n = a195065_list !! (n-1)
    a195065_list = filter (\x -> a036044 x > x) [0,2..]
    
  • Python
    def comp(s): z, o = ord('0'), ord('1'); return s.translate({z:o, o:z})
    def BCR(n): return int(comp(bin(n)[2:])[::-1], 2)
    def aupto(limit): return [m for m in range(limit+1) if BCR(m) > m]
    print(aupto(224)) # Michael S. Branicky, Jun 14 2021
Showing 1-4 of 4 results.