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 11 results. Next

A245599 Numbers m with A030101(m) XOR A030109(m) = m for the binary representation of m.

Original entry on oeis.org

1, 11, 91, 731, 5851, 46811, 374491, 2995931, 23967451, 191739611, 1533916891, 12271335131, 98170681051, 785365448411, 6282923587291, 50263388698331, 402107109586651, 3216856876693211, 25734855013545691, 205878840108365531, 1647030720866924251, 13176245766935394011
Offset: 1

Views

Author

Reinhard Muehlfeld, Jul 27 2014

Keywords

Comments

Sequence consists of all numbers with binary representation 1(011)*.

Examples

			A030101(11) = 13,  A030109(11) = 6, and 13 XOR 6 = (1101)_2 XOR (0110)_2 = (1011)_2 = 11, so 11 is in the sequence.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := (5*8^n - 12)/28; Array[a, 20] (* Giovanni Resta, Apr 25 2020 *)
  • PARI
    Vec(x*(1 + 2*x) / ((1 - x)*(1 - 8*x)) + O(x^20)) \\ Colin Barker, Apr 25 2020

Formula

a(n) = 1(011)^(n-1) in binary representation.
a(n) = (5*8^n - 12)/28. - Giovanni Resta, Apr 25 2020
From Colin Barker, Apr 25 2020: (Start)
G.f.: x*(1 + 2*x) / ((1 - x)*(1 - 8*x)).
a(n) = 9*a(n-1) - 8*a(n-2) for n>2.
(End)

Extensions

More terms from Giovanni Resta, Apr 25 2020

A030101 a(n) is the number produced when n is converted to binary digits, the binary digits are reversed and then converted back into a decimal number.

Original entry on oeis.org

0, 1, 1, 3, 1, 5, 3, 7, 1, 9, 5, 13, 3, 11, 7, 15, 1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 31, 1, 33, 17, 49, 9, 41, 25, 57, 5, 37, 21, 53, 13, 45, 29, 61, 3, 35, 19, 51, 11, 43, 27, 59, 7, 39, 23, 55, 15, 47, 31, 63, 1, 65, 33, 97, 17, 81, 49, 113, 9, 73, 41, 105, 25, 89, 57
Offset: 0

Views

Author

Keywords

Comments

As with decimal reversal, initial zeros are ignored; otherwise, the reverse of 1 would be 1000000... ad infinitum.
Numerators of the binary van der Corput sequence. - Eric Rowland, Feb 12 2008
It seems that in most cases A030101(x) = A000265(x) and that if A030101(x) <> A000265(x), the next time A030101(y) = A000265(x), A030101(x) = A000265(y). Also, it seems that if a pair of values exist at one index, they will exist at any index where one of them exist. It also seems like the greater of the pair always shows up on A000265 first. - Dylan Hamilton, Aug 04 2010
The number of occasions A030101(n) = A000265(n) before n = 2^k is A053599(k) + 1. For n = 0..2^19, the sequences match less than 1% of the time. - Andrew Woods, May 19 2012
For n > 0: a(a(n)) = n if and only if n is odd; a(A006995(n)) = A006995(n). - Juli Mallett, Nov 11 2010, corrected: Reinhard Zumkeller, Oct 21 2011
n is binary palindromic if and only if a(n) = n. - Reinhard Zumkeller, corrected: Jan 17 2012, thanks to Hieronymus Fischer, who pointed this out; Oct 21 2011
Given any n > 1, the set of numbers A030109(i) = (A030101(i) - 1)/2 for indexes i ranging from 2^n to 2^(n + 1) - 1 is a permutation of the set of consecutive integers {0, 1, 2, ..., 2^n - 1}. This is important in the standard FFT algorithms (starting or ending bit-reversal permutation). - Stanislav Sykora, Mar 15 2012
Row n of A030308 gives the binary digits of a(n), prepended with zero at even positions. - Reinhard Zumkeller, Jun 17 2012
The binary van der Corput sequence is the infinite sequence of fractions { A030101(n)/A062383(n), n = 0, 1, 2, 3, ... }, and begins 0, 1/2, 1/4, 3/4, 1/8, 5/8, 3/8, 7/8, 1/16, 9/16, 5/16, 13/16, 3/16, 11/16, 7/16, 15/16, 1/32, 17/32, 9/32, 25/32, 5/32, 21/32, 13/32, 29/32, 3/32, 19/32, 11/32, 27/32, 7/32, 23/32, 15/32, 31/32, 1/64, 33/64, 17/64, 49/64, ... - N. J. A. Sloane, Dec 01 2019
Record highs occur at n = A209492(m) (for n>=1) with values a(n) = A224195(m) (for n>=3). - Bill McEachen, Aug 02 2023

Examples

			a(100) = 19 because 100 (base 10) = 1100100 (base 2) and R(1100100 (base 2)) = 10011 (base 2) = 19 (base 10).
		

References

  • Hlawka E. The theory of uniform distribution. Academic Publishers, Berkhamsted, 1984. See pp. 93, 94 for the van der Corput sequence. - N. J. A. Sloane, Dec 01 2019

Crossrefs

Cf. A055944 (reverse and add), A178225, A273258.
Cf. A056539, A057889 (bijective variants), A224195, A209492.

Programs

  • Haskell
    a030101 = f 0 where
       f y 0 = y
       f y x = f (2 * y + b) x'  where (x', b) = divMod x 2
    -- Reinhard Zumkeller, Mar 18 2014, Oct 21 2011
    
  • J
    ([: #. [: |. #:)"0 NB. Stephen Makdisi, May 07 2018
    
  • Magma
    A030101:=func; // Jason Kimberley, Sep 19 2011
    
  • Maple
    A030101 := proc(n)
        convert(n,base,2) ;
        ListTools[Reverse](%) ;
        add(op(i,%)*2^(i-1),i=1..nops(%)) ;
    end proc: # R. J. Mathar, Mar 10 2015
    # second Maple program:
    a:= proc(n) local m, r; m:=n; r:=0;
          while m>0 do r:=r*2+irem(m, 2, 'm') od; r
        end:
    seq(a(n), n=0..80);  # Alois P. Heinz, Nov 17 2015
  • Mathematica
    Table[FromDigits[Reverse[IntegerDigits[i, 2]], 2], {i, 0, 80}]
    bitRev[n_] := Switch[Mod[n, 4], 0, bitRev[n/2], 1, 2 bitRev[(n + 1)/2] - bitRev[(n - 1)/4], 2, bitRev[n/2], 3, 3 bitRev[(n - 1)/2] - 2 bitRev[(n - 3)/4]]; bitRev[0] = 0; bitRev[1] = 1; bitRev[3] = 3; Array[bitRev, 80, 0] (* Robert G. Wilson v, Mar 18 2014 *)
  • PARI
    a(n)=if(n<1,0,subst(Polrev(binary(n)),x,2))
    
  • PARI
    a(n) = fromdigits(Vecrev(binary(n)), 2); \\ Michel Marcus, Nov 10 2017
    
  • Python
    def a(n): return int(bin(n)[2:][::-1], 2) # Indranil Ghosh, Apr 24 2017
    
  • Sage
    def A030101(n): return Integer(bin(n).lstrip("0b")[::-1],2) if n!=0 else 0
    [A030101(n) for n in (0..78)]  # Peter Luschny, Aug 09 2012
    
  • Scala
    (0 to 127).map(n => Integer.parseInt(Integer.toString(n, 2).reverse, 2)) // Alonso del Arte, Feb 11 2020

Formula

a(n) = 0, a(2n) = a(n), a(2n+1) = a(n) + 2^(floor(log_2(n)) + 1). For n > 0, a(n) = 2*A030109(n) - 1. - Ralf Stephan, Sep 15 2003
a(n) = b(n, 0) with b(n, r) = r if n = 0, otherwise b(floor(n/2), 2*r + n mod 2). - Reinhard Zumkeller, Mar 03 2010
a(1) = 1, a(3) = 3, a(2n) = a(n), a(4n+1) = 2a(2n+1) - a(n), a(4n+3) = 3a(2n+1) - 2a(n) (as in the Project Euler problem). To prove this, expand the recurrence into binary strings and reversals. - David Applegate, Mar 16 2014, following a posting to the Sequence Fans Mailing List by Martin Møller Skarbiniks Pedersen.
Conjecture: a(n) = 2*w(n) - 2*w(A053645(n)) - 1 for n > 0, where w = A264596. - Velin Yanev, Sep 12 2017

Extensions

Edits (including correction of an erroneous date pointed out by J. M. Bergot) by Jon E. Schoenfield, Mar 16 2014
Name clarified by Antti Karttunen, Nov 09 2017

A059893 Reverse the order of all but the most significant bit in binary expansion of n: if n = 1ab..yz then a(n) = 1zy..ba.

Original entry on oeis.org

1, 2, 3, 4, 6, 5, 7, 8, 12, 10, 14, 9, 13, 11, 15, 16, 24, 20, 28, 18, 26, 22, 30, 17, 25, 21, 29, 19, 27, 23, 31, 32, 48, 40, 56, 36, 52, 44, 60, 34, 50, 42, 58, 38, 54, 46, 62, 33, 49, 41, 57, 37, 53, 45, 61, 35, 51, 43, 59, 39, 55, 47, 63, 64, 96, 80, 112, 72, 104, 88, 120
Offset: 1

Views

Author

Marc LeBrun, Feb 06 2001

Keywords

Comments

A self-inverse permutation of the natural numbers.
a(n)=n if and only if A081242(n) is a palindrome. - Clark Kimberling, Mar 12 2003
a(n) is the position in B of the reversal of the n-th term of B, where B is the left-to-right binary enumeration sequence (A081242 with the empty word attached as first term). - Clark Kimberling, Mar 12 2003
From Antti Karttunen, Oct 28 2001: (Start)
When certain Stern-Brocot tree-related permutations are conjugated with this permutation, they induce a permutation on Z (folded to N), which is an infinite siteswap permutation (see, e.g., figure 7 in the Buhler and Graham paper, which is permutation A065174). We get:
A065260(n) = a(A057115(a(n))),
A065266(n) = a(A065264(a(n))),
A065272(n) = a(A065270(a(n))),
A065278(n) = a(A065276(a(n))),
A065284(n) = a(A065282(a(n))),
A065290(n) = a(A065288(a(n))). (End)
Every nonnegative integer has a unique representation c(1) + c(2)*2 + c(3)*2^2 + c(4)*2^3 + ..., where every c(i) is 0 or 1. Taking tuples of coefficients in lexical order (i.e., 0, 1; 01,11; 001,011,101,111; ...) yields A059893. - Clark Kimberling, Mar 15 2015
From Ed Pegg Jr, Sep 09 2015: (Start)
The reduced rationals can be ordered either as the Calkin-Wilf tree A002487(n)/A002487(n+1) or the Stern-Brocot tree A007305(n+2)/A047679(n). The present sequence gives the order of matching rationals in the other sequence.
For reference, the Calkin-Wilf tree is 1, 1/2, 2, 1/3, 3/2, 2/3, 3, 1/4, 4/3, 3/5, 5/2, 2/5, 5/3, 3/4, 4, 1/5, 5/4, 4/7, 7/3, 3/8, 8/5, 5/7, 7/2, 2/7, 7/5, 5/8, 8/3, 3/7, 7/4, 4/5, ..., which is A002487(n)/A002487(n+1).
The Stern-Brocot tree is 1, 1/2, 2, 1/3, 2/3, 3/2, 3, 1/4, 2/5, 3/5, 3/4, 4/3, 5/3, 5/2, 4, 1/5, 2/7, 3/8, 3/7, 4/7, 5/8, 5/7, 4/5, 5/4, 7/5, 8/5, 7/4, 7/3, 8/3, 7/2, ..., which is A007305(n+2)/A047679(n).
There is a great little OEIS-is-useful story here. I had code for the position of fractions in the Calkin-Wilf tree. The best I had for positions of fractions in the Stern-Brocot tree was the paper "Locating terms in the Stern-Brocot tree" by Bruce Bates, Martin Bunder, Keith Tognetti. The method was opaque to me, so I used my Calkin-Wilf code on the Stern-Brocot fractions, and got A059893. And thus the problem was solved. (End)

Examples

			a(11) = a(1011) = 1110 = 14.
With empty word e prefixed, A081242 becomes (e,1,2,11,21,12,22,111,211,121,221,112,...); (reversal of term #9) = (term #12); i.e., a(9)=12 and a(12)=9. - _Clark Kimberling_, Mar 12 2003
From _Philippe Deléham_, Jun 02 2015: (Start)
This sequence regarded as a triangle with rows of lengths 1, 2, 4, 8, 16, ...:
   1;
   2,  3;
   4,  6,  5,  7;
   8, 12, 10, 14,  9,  13,  11,  15;
  16, 24, 20, 28, 18,  26,  22,  30,  17,  25,  21,  29,  19,  27,  23,  31;
  32, 48, 40, 56, 36,  52,  44, ...
Row sums = A010036. (End)
		

Crossrefs

{A000027, A054429, A059893, A059894} form a 4-group.
The set of permutations {A059893, A080541, A080542} generates an infinite dihedral group.
In other bases: A351702 (balanced ternary), A343150 (Zeckendorf), A343152 (lazy Fibonacci).

Programs

  • Haskell
    a059893 = foldl (\v b -> v * 2 + b) 1 . init . a030308_row
    -- Reinhard Zumkeller, May 01 2013
    (Scheme, with memoization-macro definec)
    (definec (A059893 n) (if (<= n 1) n (let* ((k (- (A000523 n) 1)) (r (A059893 (- n (A000079 k))))) (if (= 2 (floor->exact (/ n (A000079 k)))) (* 2 r) (+ 1 r)))))
    ;; Antti Karttunen, May 16 2015
    
  • Maple
    # Implements Bottomley's formula
    A059893 := proc(n) option remember; local k; if(1 = n) then RETURN(1); fi; k := floor_log_2(n)-1; if(2 = floor(n/(2^k))) then RETURN(2*A059893(n-(2^k))); else RETURN(1+A059893(n-(2^k))); fi; 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;
    # second Maple program:
    a:= proc(n) local i, m, r; m, r:= n, 0;
          for i from 0 while m>1 do r:= 2*r +irem(m,2,'m') od;
          r +2^i
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Feb 28 2015
  • Mathematica
    A059893 = Reap[ For[n=1, n <= 100, n++, a=1; b=n; While[b > 1, a = 2*a + 2*FractionalPart[b/2]; b=Floor[b/2]]; Sow[a]]][[2, 1]] (* Jean-François Alcover, Jul 16 2012, after Harry J. Smith *)
    ro[n_]:=Module[{idn=IntegerDigits[n,2]},FromDigits[Join[{First[idn]}, Reverse[ Rest[idn]]],2]]; Array[ro,80] (* Harvey P. Dale, Oct 24 2012 *)
  • PARI
    a(n) = my(b=binary(n)); fromdigits(concat(b[1], Vecrev(vector(#b-1, k, b[k+1]))), 2); \\ Michel Marcus, Sep 29 2021
    
  • Python
    def a(n): return int('1' + bin(n)[3:][::-1], 2)
    print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Mar 21 2017
  • R
    maxrow <- 6 # by choice
    a <- 1
    for(m in 0:maxrow) for(k in 0:(2^m-1)) {
      a[2^(m+1)+    k] <- 2*a[2^m+k]
      a[2^(m+1)+2^m+k] <- 2*a[2^m+k] + 1
    }
    a
    # Yosu Yurramendi, Mar 20 2017
    
  • R
    maxblock <- 7 # by choice
    a <- 1
    for(n in 2:2^maxblock){
      ones <- which(as.integer(intToBits(n)) == 1)
      nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)]
      anbit <- nbit
      anbit[1:(length(anbit) - 1)] <- anbit[rev(1:(length(anbit)-1))]
      a <- c(a, sum(anbit*2^(0:(length(anbit) - 1))))
    }
    a
    # Yosu Yurramendi, Apr 25 2021
    

Formula

a(n) = A030109(n) + A053644(n). If 2*2^k <= n < 3*2^k then a(n) = 2*a(n-2^k); if 3*2^k <= n < 4*2^k then a(n) = 1 + a(n-2^k) starting with a(1)=1. - Henry Bottomley, Sep 13 2001

A073138 Largest number having in its binary representation the same number of 0's and 1's as n.

Original entry on oeis.org

0, 1, 2, 3, 4, 6, 6, 7, 8, 12, 12, 14, 12, 14, 14, 15, 16, 24, 24, 28, 24, 28, 28, 30, 24, 28, 28, 30, 28, 30, 30, 31, 32, 48, 48, 56, 48, 56, 56, 60, 48, 56, 56, 60, 56, 60, 60, 62, 48, 56, 56, 60, 56, 60, 60, 62, 56, 60, 60, 62, 60, 62, 62, 63, 64, 96, 96, 112, 96, 112, 112
Offset: 0

Views

Author

Reinhard Zumkeller, Jul 16 2002

Keywords

Comments

From Trevor Green (green(AT)snoopy.usask.ca), Nov 26 2003: (Start)
a(n)/n has an accumulation point at x exactly when x is in the interval [1, 2]. Proof: Clearly n <= a(n) < 2n. Let b(n) = a(n)/n, then b(n) must always lie in [1,2) and all the accumulation points of the sequence must lie in [1,2]. We shall show that every such number is an accumulation point.
First, consider any d-bit integer n. Suppose that z of these bits are 0. Let n' be the (d+z)-bit integer whose first d bits are the same as those of n and whose remaining bits are all 1. Then a(n') will have to be the (d+z)-bit integer whose first d bits are all 1 and whose last z bits are all 0.
Thus n' = (n+1)*2^z-1; a(n') = (2^d-1)2^z; and b(n') = (2^d-1)/(n+1) + epsilon, where 0 < epsilon < 2^(1-d). So to get an accumulation point x, we just choose n(d) to be the d-bit integer such that (2^d-1)/(n(d)+1) < x <= (2^d-1)/n(d), or equivalently, n(d) = floor((2^d-1)/x). If x lies in [1,2), then n(d) will always be a d-bit number for sufficiently large d.
Then n'(d) yields an increasing subsequence of the integers for which b(n'(d)) converges to x. For x = 2, choose n(d) = 2^(d-1), which is always a d-bit number; then b(n'(d)) = (2^d-1)/(2^(d-1)+1) + epsilon = 2 + epsilon', where epsilon' also heads for 0 as d blows up. This proves the claim.
(End)

Examples

			a(20)=24, as 20='10100' and 24 is the greatest number having two 1's and three 0's: 17='10001', 18='10010', 20='10100' and 24='11000'.
		

Crossrefs

Cf. A030109.
Cf. A038573.
Decimal equivalent of A221714. - N. J. A. Sloane, Jan 26 2013

Programs

  • Haskell
    a073138 n = a038573 n * a080100 n  -- Reinhard Zumkeller, Jan 16 2012
    
  • Maple
    a:= n-> Bits[Join](sort(Bits[Split](n))):
    seq(a(n), n=0..100);  # Alois P. Heinz, Jun 26 2021
  • Mathematica
    f[n_] := Module[{idn=IntegerDigits[n, 2], o, l}, l=Length[idn]; o=Count[idn, 1]; FromDigits[Join[Table[1, {o}], Table[0, {l-o}]], 2]]; Table[f[i], {i, 0, 70}]
    ln[n_] := Module[{idn=IntegerDigits[n, 2], len, zer}, len=Length[idn]; zer=Count[idn, 0]; FromDigits[Join[Table[1, {len-zer}], Table[0, {zer}]], 2]]; Table[ln[i], {i, 0, 70}]
    a[z_] := 2^(Floor[Log[2, z]] + 1) * (1 - 2^(-Sum[k, {k, IntegerDigits[n, 2]}])) Column[Table[a[p], {p, 500}], Right] (* Trevor G. Hyde (thyde12(AT)amherst.edu), Jul 14 2008 *)
    Table[FromDigits[ReverseSort[IntegerDigits[n,2]],2],{n,0,70}] (* Harvey P. Dale, Mar 13 2023 *)
  • PARI
    a(n) = fromdigits(vecsort(binary(n),,4), 2); \\ Michel Marcus, Sep 26 2018
    
  • Python
    def a(n): return int("".join(sorted(bin(n)[2:], reverse=True)), 2)
    print([a(n) for n in range(71)]) # Michael S. Branicky, Jun 27 2021
    
  • Python
    def A073138(n): return (m:=1<>n.bit_count()) # Chai Wah Wu, Aug 18 2025

Formula

a(n+1) = a(floor(n/2))*2 + (n mod 2)*(2^floor(log_2(n)) - a(floor(n/2))); a(0)=0.
A023416(a(n)) = A023416(n), A000120(a(n)) = A000120(n).
a(0)=0, a(1)=1, a(2n) = 2a(n), a(2n+1) = a(n) + 2^floor(log_2(n)). - Ralf Stephan, Oct 05 2003
a(n) = 2^(floor(log_2(n)) + 1) * (1 - 2^(-d(n))) where d(n) = digit sum of base-2 expansion of n. - Trevor G. Hyde (thyde12(AT)amherst.edu), Jul 14 2008
a(n) = A038573(n) * A080100(n). - Reinhard Zumkeller, Jan 16 2012
n <= a(n) < 2n. - Charles R Greathouse IV, Aug 07 2024

A049773 Triangular array T read by rows: if row n is r(1),...,r(m), then row n+1 is 2r(1)-1,...,2r(m)-1,2r(1),...,2r(m).

Original entry on oeis.org

1, 1, 2, 1, 3, 2, 4, 1, 5, 3, 7, 2, 6, 4, 8, 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16, 1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 31, 2, 18, 10, 26, 6, 22, 14, 30, 4, 20, 12, 28, 8, 24, 16, 32, 1, 33, 17, 49, 9, 41, 25, 57, 5, 37, 21, 53, 13, 45, 29, 61, 3, 35, 19
Offset: 1

Views

Author

Keywords

Comments

n-th row = (r(1),r(2),...,r(m)), where m=2^(n-1), satisfies r(r(k))=k for k=1,2,...,m and has exactly 2^[ n/2 ] solutions of r(k)=k. (The function r(k) reverses bits. Or rather, r(k)=revbits(k-1)+1.)
In a knockout competition with m players, arranging the competition brackets (see links) in r(k) order, where k is the rank of the player, ensures that highest ranked players cannot meet until the later stages of the competition. None of the top 2^p ranked players can meet earlier than the p-th from last round of the competition. At the same time the top ranked players in each match meet the highest ranked player possible consistent with this rule. The sequence for the top ranked players meeting the lowest ranked player possible is A131271. - Colin Hall, Jul 31 2011, Feb 29 2012
Row n contains one of A003407(2^(n-1)) non-averaging permutations of [2^(n-1)], i.e., a permutation of [2^(n-1)] without 3-term arithmetic progressions. - Alois P. Heinz, Dec 05 2017

Examples

			Triangle begins:
1;
1,  2;
1,  3, 2,  4;
1,  5, 3,  7, 2,  6,  4,  8;
1,  9, 5, 13, 3, 11,  7, 15, 2, 10,  6, 14, 4, 12,  8, 16;
1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 31, 2, 18, 10, 26, ...
		

Crossrefs

Sum of odd-indexed terms of n-th row gives A007582. Sum of even-indexed terms gives A049775.
A030109 is another version.
Cf. A131271.
Cf. A088370.

Programs

  • Haskell
    a049773 n k = a049773_tabf !! (n-1) !! (k-1)
    a049773_row n = a049773_tabf !! (n-1)
    a049773_tabf = iterate f [1] where
       f vs = (map (subtract 1) ws) ++ ws where ws = map (* 2) vs
    -- Reinhard Zumkeller, Mar 14 2015
  • Maple
    T:= proc(n) option remember; `if`(n=1, 1,
          [map(x->2*x-1, [T(n-1)])[], map(x->2*x, [T(n-1)])[]][])
        end:
    seq(T(n), n=1..7);  # Alois P. Heinz, Oct 28 2011
  • Mathematica
    row[1] = {1}; row[n_] := row[n] = Join[ 2*row[n-1] - 1, 2*row[n-1] ]; Flatten[ Table[ row[n], {n, 1, 7}]] (* Jean-François Alcover, May 03 2012 *)
  • PARI
    (a(n, k) = if( k<=0 || k>=n, 0, if( k%2, n\2) + a(n\2, k\2))); {T(n, k) = if( k<=0 || k>2^n/2, 0, 1 + a(2^n/2, k-1))}; /* Michael Somos, Oct 13 1999 */
    

A055945 a(n) = n - (reversal of base-2 digits of n) (and then the result is written in base 10).

Original entry on oeis.org

0, 0, 1, 0, 3, 0, 3, 0, 7, 0, 5, -2, 9, 2, 7, 0, 15, 0, 9, -6, 15, 0, 9, -6, 21, 6, 15, 0, 21, 6, 15, 0, 31, 0, 17, -14, 27, -4, 13, -18, 35, 4, 21, -10, 31, 0, 17, -14, 45, 14, 31, 0, 41, 10, 27, -4, 49, 18, 35, 4, 45, 14, 31, 0, 63, 0, 33, -30, 51, -12, 21, -42, 63, 0, 33, -30, 51, -12, 21, -42, 75, 12, 45, -18, 63, 0, 33, -30, 75, 12, 45
Offset: 0

Views

Author

Henry Bottomley, Jul 18 2000

Keywords

Comments

a(n) is even if n is odd and a(n) is odd if n is even; this is caused by the kind of swapping the most significant and least significant binary digit when reversing n and the fact that the most significant digit of n is always 1. - R. J. Mathar, Nov 05 2015

Crossrefs

Programs

  • Maple
    a:= proc(n) local m, r; m:=n; r:=0;
          while m>0 do r:= r*2 +irem(m, 2, 'm') od;
          n-r
        end:
    seq(a(n), n=0..100);  # Alois P. Heinz, Jul 02 2015
  • Mathematica
    Array[# - IntegerReverse[#, 2] &, 90, 0] (* Michael De Vlieger, Sep 06 2019 *)

Formula

For 2^m <= n <= 2^(m+1), we have n - 2^(m+1) <= a(n) <= n. - N. J. A. Sloane, May 29 2016
a(n) = n - A030101(n).

A353654 Numbers whose binary expansion has the same number of trailing 0 bits as other 0 bits.

Original entry on oeis.org

1, 3, 7, 10, 15, 22, 26, 31, 36, 46, 54, 58, 63, 76, 84, 94, 100, 110, 118, 122, 127, 136, 156, 172, 180, 190, 204, 212, 222, 228, 238, 246, 250, 255, 280, 296, 316, 328, 348, 364, 372, 382, 392, 412, 428, 436, 446, 460, 468, 478, 484, 494, 502, 506, 511, 528, 568
Offset: 1

Views

Author

Mikhail Kurkov, Jul 15 2022

Keywords

Comments

Numbers k such that A007814(k) = A086784(k).
To reproduce the sequence through itself, use the following rule: if binary 1xyz is a term then so are 11xyz and 10xyz0 (except for 1 alone where 100 is not a term).
The number of terms with bit length k is equal to Fibonacci(k-1) for k > 1.
Conjecture: 2*A247648(n-1) + 1 with rewrite 1 -> 1, 01 -> 0 applied to binary expansion is the same as a(n) without trailing 0 bits in binary.
Odd terms are positive Mersenne numbers (A000225), because there is no 0 in their binary expansion. - Bernard Schott, Oct 12 2022

Crossrefs

Cf. A356385 (first differences).
Subsequences with same number k of trailing 0 bits and other 0 bits: A000225 (k=0), 2*A190620 (k=1), 4*A357773 (k=2), 8*A360573 (k=3).

Programs

  • Maple
    N:= 10: # for terms <= 2^N
    S:= {1};
    for d from 1 to N do
      for k from 0 to d/2-1 do
        B:= combinat:-choose([$k+1..d-2],k);
        S:= S union convert(map(proc(t) local s; 2^d - 2^k - add(2^(s),s=t) end proc,B),set);
    od od:
    sort(convert(S,list)); # Robert Israel, Sep 21 2023
  • Mathematica
    Join[{1}, Select[Range[2, 600], IntegerExponent[#, 2] == Floor[Log2[# - 1]] - DigitCount[# - 1, 2, 1] &]] (* Amiram Eldar, Jul 16 2022 *)
  • PARI
    isok(k) = if (k==1, 1, (logint(k-1, 2)-hammingweight(k-1) == valuation(k, 2))); \\ Michel Marcus, Jul 16 2022
    
  • Python
    from itertools import islice, count
    def A353654_gen(startvalue=1): # generator of terms >= startvalue
        return filter(lambda n:(m:=(~n & n-1).bit_length()) == bin(n>>m)[2:].count('0'),count(max(startvalue,1)))
    A353654_list = list(islice(A353654_gen(),30)) # Chai Wah Wu, Oct 14 2022

Formula

a(n) = a(n-1) + A356385(n-1) for n > 1 with a(1) = 1.
Conjectured formulas: (Start)
a(n) = 2^g(n-1)*(h(n-1) + 2^A000523(h(n-1))*(2 - g(n-1))) for n > 2 with a(1) = 1, a(2) = 3 where f(n) = n - A130312(n), g(n) = [n > 2*f(n)] and where h(n) = a(f(n) + 1).
a(n) = 1 + 2^r(n-1) + Sum_{k=1..r(n-1)} (1 - g(s(n-1, k)))*2^(r(n-1) - k) for n > 1 with a(1) = 1 where r(n) = A072649(n) and where s(n, k) = f(s(n, k-1)) for n > 0, k > 1 with s(n, 1) = n.
a(n) = 2*(2 + Sum_{k=1..n-2} 2^(A213911(A280514(k)-1) + 1)) - 2^A200650(n) for n > 1 with a(1) = 1.
A025480(a(n)-1) = A348366(A343152(n-1)) for n > 1.
a(A000045(n)) = 2^(n-1) - 1 for n > 1. (End)

A239303 Triangle of compressed square roots of Gray code * bit-reversal permutation.

Original entry on oeis.org

1, 3, 1, 6, 1, 5, 6, 9, 1, 10, 12, 18, 1, 17, 10, 12, 18, 33, 1, 34, 20, 24, 36, 66, 1, 65, 34, 20, 24, 36, 66, 129, 1, 130, 68, 40, 48, 72, 132, 258, 1, 257, 130, 68, 40, 48, 72, 132, 258, 513, 1, 514, 260, 136, 80
Offset: 1

Views

Author

Tilman Piesk, Mar 14 2014

Keywords

Comments

The permutation that turns a natural ordered into a sequency ordered Walsh matrix of size 2^n is the product of the Gray code permutation A003188(0..2^n-1) and the bit-reversal permutation A030109(n,0..2^n-1).
(This permutation of 2^n elements can be represented by the compression vector [2^(n-1), 3*[2^(n-2)..4,2,1]] with n elements.)
This triangle shows the compression vectors of the unique square roots of these permutations, which correspond to symmetric binary matrices with 2n-1 ones.
(These n X n matrices correspond to graphs that can be described by permutations of n elements, which are shown in A239304.)
Rows of the square array:
T(1,n) = 1,3,6,6,12,12,24,24,48,48,96,96,192,192,384,384,... (compare A003945)
T(2,n) = 1,1,9,18,18,36,36,72,72,144,144,288,288,576,576,... (compare A005010)
Columns of the square array:
T(m,1) = 1,1,5,10,10,20,20,40,40,80,80,160,160,320,320,... (compare A146523)
T(m,2) = 3,1,1,17,34,34,68,68,136,136,272,272,544,544,... (compare A110287)

Examples

			Triangular array begins:
   1
   3   1
   6   1   5
   6   9   1  10
  12  18   1  17  10
  12  18  33   1  34  20
Square array begins:
   1   3   6   6  12  12
   1   1   9  18  18  36
   5   1   1  33  66  66
  10  17   1   1 129 258
  10  34  65   1   1 513
  20  34 130 257   1   1
The Walsh permutation wp(8,12,6,3) = (0,8,12,4, 6,14,10,2, 3,11,15,7, 5,13,9,1) permutes the natural ordered into the sequency ordered Walsh matrix of size 2^4.
Its square root is wp(6,9,1,10) = (0,6,9,15, 1,7,8,14, 10,12,3,5, 11,13,2,4).
So row 4 of the triangular array is (6,9,1,10).
		

Crossrefs

A074894 Full list of counterexamples for the k=3 version of the malicious apprentice problem.

Original entry on oeis.org

3, 6, 27, 486
Offset: 1

Views

Author

N. J. A. Sloane, based on email from R. K. Guy, Oct 30 2008

Keywords

Comments

This is the problem of the farmer's helper who, when asked to weigh n bags of grain, does so k at a time and reports the resulting binomial(n,k) combined weights with no indication of the k-tuples that produced them. The problem: is can the weights of the bags be recovered?
For k=3 the answer is Yes unless n is one of the four terms of this sequence. For k=2 see A057716.
The old entry with this sequence number was a duplicate of A030109.
The following references also apply to the general case of the problem.

Examples

			For n=27 Boman and Linusson give five examples of which the simplest is {-4,-1^{10},2^{16}} and its negative, where exponents denote repetitions. For n=486 Boman and Linusson give {-7,-4^{56},-1^{231},2^{176},5^{22}} and its negative.
		

References

  • W. W. Rouse Ball, A Short Account of the History of Mathematics.
  • E. Bolker, The finite Radon transform, Contemp. Math., 63 (1987) 27-50.
  • R. K. Guy, Unsolved Problems in Number Theory, C5.
  • Ross A. Honsberger, A gem from combinatorics, Bull. ICA, 1 (1991) 56-58.
  • B. Liu and X. Zhang, On harmonious labelings of graphs, Ars Combin., 36 (1993) 315-326.
  • J. Ossowski, On a problem of Galvin, Congressus Numerantium, 96 (1993) 65-74.
  • P. Winkler, Mathematical Mind-Benders, Peters, Wellesley, MA, 2007; see p. 27.

Crossrefs

See A057716 for the case k=2.

A195665 Consecutive bit-permutations of nonnegative integers.

Original entry on oeis.org

0, 1, 0, 2, 1, 3, 0, 1, 4, 5, 2, 3, 6, 7, 0, 2, 4, 6, 1, 3, 5, 7, 0, 4, 1, 5, 2, 6, 3, 7, 0, 4, 2, 6, 1, 5, 3, 7, 0, 1, 2, 3, 8, 9, 10, 11, 4, 5, 6, 7, 12, 13, 14, 15, 0, 2, 1, 3, 8, 10, 9, 11, 4, 6, 5, 7, 12, 14, 13, 15, 0, 1, 4, 5, 8, 9, 12
Offset: 0

Views

Author

Tilman Piesk, Sep 23 2011

Keywords

Comments

All rows of this array are infinite permutations of the nonnegative integers. Row m (counted from 0) is always generated by modifying the sequence of nonnegative integers in the following way: The sequence of integers is written in reverse binary. Than the finite permutation p_m (row m of array A055089) is applied on the digits of all entries.
The rows of the top left n! X 2^n submatrix describe the rotations and reflections of the n-hypercube that preserve the binary digit sums of the vertex numbers. With permutation composition these permutations form the symmetric group S_n.
Applying such a permutation on the binary string of a Boolean function gives the string of a function in the same big equivalence class (compare A227723).
Triangle row m has length 2^n for m in the interval [(n-1)!,n![. The rest of the array row repeats the same pattern. The first digit of the rest is the digit before plus one.

Examples

			Top left corner of array:
0 1 2 3 4 5 6 7
0 2 1 3 4 6 5 7
0 1 4 5 2 3 6 7
0 2 4 6 1 3 5 7
0 4 1 5 2 6 3 7
0 4 2 6 1 5 3 7
The entry in row 2, column 5 (both counted from 0) is 3: 5 in reverse binary is 101, permutation p_2 applied on 101 gives 110, 110 from reverse binary to decimal is 3.
Corresponding rows of the triangle:
0 1
0 2 1 3
0 1 4 5 2 3 6 7
0 2 4 6 1 3 5 7
0 4 1 5 2 6 3 7
0 4 2 6 1 5 3 7
		

Crossrefs

The finite permutations in A055089 are applied on the reverse binary digits.
Row 0: A001477.
Row 1: A080412.
Row n!-1 of the triangle is the n-bit bit-reversal permutation. Compare A030109.

Extensions

Huge edit by Tilman Piesk, Aug 01 2013
Showing 1-10 of 11 results. Next