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

A256999 a(n)=n for n <= 1; for n >= 2, a(n) = largest number that can be obtained by rotating non-msb bits of binary expansion of n (with A080541 or A080542).

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, 26, 28, 30, 24, 28, 26, 30, 28, 30, 30, 31, 32, 48, 48, 56, 48, 52, 56, 60, 48, 52, 52, 58, 56, 58, 60, 62, 48, 56, 52, 60, 52, 58, 58, 62, 56, 60, 58, 62, 60, 62, 62, 63, 64, 96, 96, 112, 96, 104, 112, 120, 96, 100, 104, 114, 112, 116, 120, 124, 96, 104, 100
Offset: 0

Views

Author

Antti Karttunen, May 16 2015

Keywords

Crossrefs

Cf. A257250 (fixed points of this sequence).
Cf. also A163380 (analogous sequence when rotating all bits of binary representation).

A257250 Numbers n for which A256999(n) = n; numbers that cannot be made any larger by rotating (by one or more steps) the non-msb bits of their binary representation (with A080541 or A080542).

Original entry on oeis.org

0, 1, 2, 3, 4, 6, 7, 8, 12, 14, 15, 16, 24, 26, 28, 30, 31, 32, 48, 52, 56, 58, 60, 62, 63, 64, 96, 100, 104, 106, 112, 114, 116, 118, 120, 122, 124, 126, 127, 128, 192, 200, 208, 212, 224, 226, 228, 232, 234, 236, 240, 242, 244, 246, 248, 250, 252, 254, 255, 256, 384, 392, 400, 416, 420, 424, 426, 448, 450
Offset: 0

Views

Author

Antti Karttunen, May 16 2015

Keywords

Comments

These correspond to the maximal (lexicographically largest) representatives selected from each equivalence class of binary necklaces. See the last example.
Indexing starts from zero, because a(0) = 0 is a special case.
If k is a member then so also is 2*k, i.e., k with 0 appended to the end of its binary representation.
If k is a member then so also is A004755(k), i.e., k with 1 prepended to the front of its binary representation.
One obtains A065609 if one erases the most significant bit of each term [as A053645(a(n))] and then discards any zero-terms produced from the terms that originally were powers of two (A000079).
First differs from A328607 in lacking 108, with binary expansion 1101100. If we define a dual-necklace to be a finite sequence that is lexicographically maximal (not minimal) among all of its cyclic rotations, these are numbers whose binary expansion, without the most significant digit, is a dual-necklace. - Gus Wiseman, Nov 04 2019

Examples

			For n = 5, with binary representation "101", if we rotate other bits than the most significant bit (that is, only the two rightmost digits "01") one step to either direction, we get "110" = 6 > 5, so 5 can be made larger by such rotations, and thus is NOT included in this sequence.
For n = 6, with binary representation "110", no such rotation will yield a larger number, and thus 6 is included in this sequence.
For n = 28, with binary representation "11100", if we rotate non-msb bits towards right, we get additional numbers 22, 19 and 25 (with binary representations "10110", "10011", "11001") before coming to 28 again, and 28 is the largest of these numbers, thus 28 is included in this sequence.
  Also, if we discard the most significant bit of each and consider them just as binary strings, then A053645(28) = 12 is the lexicographically largest representative of {"1100", "0110", "0011", "1001"}, which is the complete set of representatives for a particular equivalence class of binary necklaces, obtained by rotating all bits of binary string "1100" successively towards right or left.
		

Crossrefs

Complement: A257739.
Odd terms: A000225.
Subsequence of A065609.
Subsequence: A258003.
The non-dual version is A328668.
The version involving all digits is A065609.
The non-dual reversed version is A328607.
Numbers whose reversed binary expansion is a necklace are A328595.
Binary necklaces are A000031.
Necklace compositions are A008965.

Programs

  • Mathematica
    reckQ[q_]:=Array[OrderedQ[{RotateRight[q,#],q}]&,Length[q]-1,1,And];
    Select[Range[0,110],#<=1||reckQ[Rest[IntegerDigits[#,2]]]&] (* Gus Wiseman, Nov 04 2019 *)

A257739 Numbers n for which A256999(n) > n; numbers that can be made larger by rotating (by one or more steps) the non-msb bits of their binary representation (with A080541 or A080542).

Original entry on oeis.org

5, 9, 10, 11, 13, 17, 18, 19, 20, 21, 22, 23, 25, 27, 29, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 53, 54, 55, 57, 59, 61, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 97, 98, 99, 101, 102, 103, 105, 107, 108, 109, 110, 111
Offset: 1

Views

Author

Antti Karttunen, May 18 2015

Keywords

Comments

Note that A256999(a(n)) is always in A257250.
If we define a co-necklace to be a finite sequence that is lexicographically maximal (not minimal) among all of its cyclic rotations, these are numbers whose binary expansion, without the most significant digit, is not a co-necklace. Numbers whose binary expansion, without the most significant digit, is not a necklace are A329367. - Gus Wiseman, Nov 14 2019

Examples

			For n = 5 with binary representation "101" if we rotate other bits than the most significant bit (that is, only the two rightmost digits "01") one step to either direction we get "110" = 6 > 5, so 5 can be made larger by such rotations and thus 5 is included in this sequence.
For n = 6 with binary representation "110" no such rotation will yield a larger number and thus 6 is NOT included in this sequence.
For n = 10 with binary representation "1010" if we rotate other bits than the most significant bit (that is, only the three rightmost digits "010") either one step to the left or two steps to the right we get "1100" = 12 > 10, thus 10 is included in this sequence.
		

Crossrefs

Complement: A257250.
Numbers whose binary expansion is a necklace are A275692.
Numbers whose binary expansion is a co-necklace are A065609.
Numbers whose reversed binary expansion is a necklace are A328595.
Numbers whose non-msb expansion is a co-necklace are A257250.
Numbers whose non-msb expansion is a necklace are A328668.
Numbers whose reversed non-msb expansion is a necklace are A328607.
Numbers whose non-msb expansion is not a necklace are A329367.
Binary necklaces are A000031.
Necklace compositions are A008965.

Programs

  • Mathematica
    reckQ[q_]:=Array[OrderedQ[{RotateRight[q,#],q}]&,Length[q]-1,1,And];
    Select[Range[2,100],!reckQ[Rest[IntegerDigits[#,2]]]&] (* Gus Wiseman, Nov 14 2019 *)

A257697 a(n)=0 for n <= 1; for n >= 2, a(n) = largest number that can be obtained by rotating non-msb bits of binary expansion of n (with A080541 or A080542), without the most significant bit of n: a(n) = A053645(A256999(n)).

Original entry on oeis.org

0, 0, 0, 1, 0, 2, 2, 3, 0, 4, 4, 6, 4, 6, 6, 7, 0, 8, 8, 12, 8, 10, 12, 14, 8, 12, 10, 14, 12, 14, 14, 15, 0, 16, 16, 24, 16, 20, 24, 28, 16, 20, 20, 26, 24, 26, 28, 30, 16, 24, 20, 28, 20, 26, 26, 30, 24, 28, 26, 30, 28, 30, 30, 31, 0, 32, 32, 48, 32, 40, 48, 56, 32, 36, 40, 50, 48, 52, 56, 60, 32, 40, 36, 52, 40, 42, 50, 58, 48, 50, 52, 54, 56, 58, 60
Offset: 0

Views

Author

Antti Karttunen, May 16 2015

Keywords

Comments

For each n, apart from powers of 2, a(n) gives the lexicographically largest representative from the equivalence class of binary necklaces obtained by successively rotating (with A080541 or A080542) all the other bits than the most significant bit in the binary representation of n.

Crossrefs

Programs

Formula

a(n) = A053645(A256999(n)).
Other identities and observations:
For all n >= 0, a(n) >= A053645(n).
Apart from powers of 2 (A000079), for any other n, a(n) >= A072376(n).

A258001 Those terms of A255571 whose every A080541/A080542-rotation is also a term of A255571.

Original entry on oeis.org

1, 64, 127, 1057, 1090, 1156, 1288, 1519, 1552, 1783, 1915, 1981, 2014, 4369, 4642, 5188, 6007, 6280, 7099, 7645, 7918, 16963, 17029, 17161, 17542, 17545, 17674, 17938, 18529, 18577, 18700, 18706, 18964, 19492, 20335, 20641, 20674, 20770, 21016, 21028, 21544, 22447, 22600, 23479, 23503, 23995, 24187, 24253, 24286, 24865, 24898, 24964
Offset: 0

Views

Author

Antti Karttunen, May 16 2015

Keywords

Comments

These are the numbers whose binary representation traces a nonselfcrossing circuit in honeycomb lattice when its bits (from the least to the second most significant bit; the most significant 1-bit is ignored) are interpreted as directions to proceed at each vertex, with an additional condition that the final direction (angle) must be equal to the starting direction of the walk. Because each bit either adds or subtracts 60 degrees from the current phase angle, it implies that for all terms after the initial term a(1)=0 (which stands for an empty path), the difference between the number of 0-bits and 1-bits (when excluding the most significant bit which is always 1) must be either -6 or +6. And indeed, for all n >= 1, A037861(a(n)) is either 5 or -7 as A037861 takes also the most significant bit into account.

Crossrefs

Subsequence of A255571.
Cf. A258002 (a subsequence; terms that have more ones than zeros in their binary representation).

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

A080542 In binary representation: keep the first digit and rotate right the others.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Feb 20 2003

Keywords

Comments

Permutation of natural numbers with inverse = A080541: A080541(a(n)) = a(A080541(n)) = n;
let r(n,0)=n, r(n,k)=a(r(n,k-1)) for k>0, then r(n,floor(log_2(n))) = n and for n>1: r(n,floor(log_2(n))-1) = A080541(n).
Discarding their most significant bit, binary representations of numbers present in each cycle of this permutation form a distinct equivalence class of binary necklaces, thus there are A000031(n) separate cycles in each range [2^n .. (2^(n+1))-1] (for n >= 0) of this permutation. A256999 gives the largest number present in n's cycle. - Antti Karttunen, May 16 2015

Examples

			a(20) = a('10100') = '10010' = 18.
a(25) = a('11001') = '11100' = 28.
		

Crossrefs

Inverse: A080541.
The set of permutations {A059893, A080541, A080542} generates an infinite dihedral group.

Programs

  • Mathematica
    kfd[n_]:=Module[{a,b},{a,b}=TakeDrop[IntegerDigits[n,2],1];FromDigits[ Join[a,RotateRight[b]],2]]; Array[kfd,80] (* The program uses the TakeDrop function from Mathematica version 10 *) (* Harvey P. Dale, Feb 12 2016 *)
  • Python
    def A080542(n): return (1+(n&1))*(1<>1) if n > 1 else n # Chai Wah Wu, Jan 22 2023
  • R
    nmax <- 31 # by choice
    a <- 1:3
    for(n in 1:nmax) for(k in 0:3)
    a[4*n + k] = 2*a[2*n + (k == 1 | k == 3)] + (k == 2 | k == 3)
    a
    # Yosu Yurramendi, Sep 05 2020
    
  • Scheme
    (define (A080542 n) (if (< n 2) n (+ (A053644 n) (+ (* (A000035 n) (A072376 n)) (A004526 (A053645 n))))))  ;; Antti Karttunen, May 16 2015
    

Formula

a(n) = 2^log2(n) + floor((n-2^log2(n))/2) + (n mod 2)*2^(log2(n)-1), where log2(n) is the integer part of base-2 logarithm.
From Antti Karttunen, May 16 2015: (Start)
a(1) = 1; for n > 1, a(n) = A053644(n) + (A000035(n)*A072376(n)) + A004526(A053645(n)). [Essentially the same formula but represented with A-numbers.]
Other identities. For all n >= 1:
a(n) = A059893(A080541(A059893(n))).
a(n) = A054429(a(A054429(n))).
(End)

A258003 Capped binary boundary codes for holeless strictly non-overlapping polyhexes, only the maximal representative from each equivalence class obtained by rotating.

Original entry on oeis.org

1, 127, 2014, 7918, 31606, 32122, 32188, 126394, 127930, 128476, 486838, 503254, 503482, 505306, 505564, 506332, 511450, 511462, 511708, 511804, 513514, 513772, 513778, 514540, 514804, 514936, 2012890, 2012902, 2013916, 2021098, 2021212, 2022124, 2025196, 2039254, 2043610, 2043622, 2045674, 2045788, 2046700
Offset: 0

Views

Author

Antti Karttunen, May 16 2015

Keywords

Comments

Indexing starts from zero, because a(0) = 1 is a special case, indicating an empty path, which thus ends at the same vertex as where it started from.
A258204(n) gives the count of terms with binary width 2n + 1.

Crossrefs

Intersection of A257250 and A258002.
Subsequence of A258013.
Subsequence: A258005.
Cf. also A258004 (the same terms without the most significant bit, slightly more compact representation).

A258002 Capped binary boundary codes for holeless strictly non-overlapping polyhexes (all orientations and rotations included).

Original entry on oeis.org

1, 127, 1519, 1783, 1915, 1981, 2014, 6007, 7099, 7645, 7918, 20335, 22447, 23479, 23503, 23995, 24187, 24253, 24286, 26551, 27607, 28123, 28135, 28381, 28477, 28510, 29659, 30187, 30445, 30451, 30574, 30622, 31213, 31477, 31606, 31609, 31990, 32122, 32188, 80815, 81271, 89527, 89551, 89719, 93655, 93883, 95191, 95707, 95719, 95965, 96061
Offset: 0

Views

Author

Antti Karttunen, May 16 2015

Keywords

Comments

The sequence consists of those terms of A255571 whose every A080541/A080542-rotation is also a term of A255571 and in their binary representation the number of 1's is larger than the number of 0's. More precisely, after the initial term a(0)=1 (which stands for an empty path) each term has seven more 1's than 0's in their binary representation, i.e., A037861(a(n)) = -7 for all n >= 1.

Examples

			8167737748888 is included in the sequence, as it encodes a 42-edge polyhex pattern which is composed of two seven-hex "crowns" connected by a snake-like "S-piece".
		

Crossrefs

Intersection of A072600 and A258001.
Intersection of A255571 and A258012.
Subsequence: A258003 (lexicographically largest representatives).
Cf. A037861.
Differs from A258012 for the first time at n=6622.

A080543 In binary representation: keep the first digit and rotate left the others twice.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Feb 20 2003

Keywords

Comments

a(n) = A080541(A080541(n)); permutation of natural numbers with inverse = A080544: A080544(a(n)) = a(A080544(n)) = n.

Examples

			a(20) = a('10100') = '100001' = 17; a(24) = a('11000') = '10010' = 18.
		

Crossrefs

Programs

  • Mathematica
    Table[FromDigits[Prepend[RotateLeft[Rest[IntegerDigits[n, 2]], 2], 1], 2], {n, 72}] (* Ivan Neretin, Aug 30 2015 *)
Showing 1-10 of 11 results. Next