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

A080412 Exchange rightmost two binary digits of n > 1; a(0)=0, a(1)=2.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Feb 17 2003

Keywords

Comments

Self-inverse permutation of the natural numbers: a(a(n)) = n.
Lodumo_2 of A021913. - Philippe Deléham, Apr 26 2009
The lodumo_m transformation of a list L is the list L' such that L'(n) is the smallest nonnegative integer not occurring earlier in L' and equal to L(n) (mod m). - M. F. Hasler, Dec 06 2010
From Franck Maminirina Ramaharo, Jul 20 2018: (Start)
Let
A: 0, 3, 8, 11, 16, 19, 24, 27, 32, 35, 40, 43, 48, 51, 56, 59, ... A047470
B: 1, 6, 9, 14, 17, 22, 25, 30, 33, 38, 41, 46, 49, 54, 57, 62, ... A047452
C: 2, 5, 10, 13, 18, 21, 26, 29, 34, 37, 42, 45, 50, 53, 58, 61, ... A047617
D: 4, 7, 12, 15, 20, 23, 28, 31, 36, 39, 44, 47, 52, 55, 60, 63, ... A047535.
Then the sequence is obtained by repeatedly picking terms from A,B,C,D according to the circuit A-C-B-A-D-B-C-D. The sequence begins:
A | C | B | A | D | B | C | D || A | C | B | A | D | ...
--+---+---+---+---+---+---+---++---+---+---+---+---+----
0 | 2 | 1 | 3 | 4 | 6 | 5 | 7 || 8 |10 | 9 |11 |12 | ...
(End)
The sequence is a permutation of the nonnegative integers partitioned into quadruples [4k, 4k+2, 4k+1, 4k+3] for k >= 0, i.e., the two interior terms of each quadruple are interchanged. - Guenther Schrack, Apr 22 2019

Examples

			a(20) = a('101'00') = '101'00' = 20; a(21) = a('101'01') = '101'10' = 22.
a(2) = a('10') = '01' = 1; a(3) = a('11') = '11' = 3.
		

Crossrefs

Programs

  • GAP
    a:=[0,2,1,3,4];; for n in [6..80] do a[n]:=a[n-1]+a[n-4]-a[n-5]; od; a; # Muniru A Asiru, Jul 27 2018
    
  • Magma
    R:=PowerSeriesRing(Integers(), 80); [0] cat Coefficients(R!( x*(2-x+2*x^2+x^3)/((1-x)*(1-x^4)) )); // G. C. Greubel, Apr 28 2019
    
  • Maple
    A080412:=n->n+1+(1+I)*(2*I-2-(1-I)*I^(2*n)+I^(-n)-I^(1+n))/4: seq(A080412(n), n=0..100); # Wesley Ivan Hurt, May 28 2016
  • Mathematica
    a[n_] := (bits = IntegerDigits[n, 2]; Join[Drop[bits, -2], {bits[[-1]], bits[[-2]]}] // FromDigits[#, 2]&); a[0]=0; a[1]=2; Table[a[n], {n, 0, 80}] (* Jean-François Alcover, Mar 11 2013 *)
    ertbd[n_]:=Module[{a,b},{a,b}=TakeDrop[IntegerDigits[n,2], IntegerLength[ n,2]-2];FromDigits[Join[a,Reverse[b]],2]]; Join[{0,2},Array[ertbd,80,2]] (* The program uses the TakeDrop function from Mathematica version 10 *) (* Harvey P. Dale, Jan 07 2016 *)
    CoefficientList[Series[x*(2-x+2*x^2+x^3)/((1-x)*(1-x^4)), {x,0,80}], x] (* G. C. Greubel, Apr 28 2019 *)
  • PARI
    my(x='x+O('x^80)); concat([0], Vec(x*(2-x+2*x^2+x^3)/((1-x)*(1-x^4)))) \\ G. C. Greubel, Apr 28 2019
    
  • Python
    def A080412(n): return (0,1,-1,0)[n&3]+n # Chai Wah Wu, Jan 18 2023
  • Sage
    (x*(2-x+2*x^2+x^3)/((1-x)*(1-x^4))).series(x, 80).coefficients(x, sparse=False) # G. C. Greubel, Apr 28 2019
    

Formula

a(n) = 4*floor(n/4) + a(n mod 4), for n > 3.
a(n) = a(n-1) + a(n-4) - a(n-5) for n > 4. - Joerg Arndt, Mar 11 2013
a(n) = lod_2(A021913(n)). - Philippe Deléham, Apr 26 2009
From Wesley Ivan Hurt, May 28 2016: (Start)
a(n) = n + 1 + (1+i)*(2*i-2-(1-i)*i^(2*n) + i^(-n)-i^(1+n))/4 where i=sqrt(-1).
G.f.: x*(2-x+2*x^2+x^3) / ((1-x)^2*(1+x+x^2+x^3)). (End)
E.g.f.: (sin(x) + cos(x) + (2*x + 1)*sinh(x) + (2*x - 1)*cosh(x))/2. - Ilya Gutkovskiy, May 28 2016
From Guenther Schrack, Apr 23 2019: (Start)
a(n) = (2*n - (-1)^n + (-1)^(n*(n-1)/2))/2.
a(n) = a(n-4) + 4, a(0)=0, a(1)=2, a(2)=1, a(3)=3, for n > 3. (End)

Extensions

Typo in example fixed by Reinhard Zumkeller, Jul 06 2009

A080541 In binary representation: keep the first digit and left-rotate the others.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Feb 20 2003

Keywords

Comments

Permutation of natural numbers: 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) = A080542(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')='11000'=24; a(24)=a('11000')='10001'=17.
		

Crossrefs

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

Programs

  • Maple
    f:= proc(n) local d;
       d:= ilog2(n);
       if n >= 3/2*2^d then 2*n+1-2^(d+1) else 2*n - 2^d fi
    end proc:
    map(f, [$1..100]); # Robert Israel, May 19 2015
  • Mathematica
    A080541[n_] := FromDigits[Join[{First[#]}, RotateLeft[Rest[#]]], 2] & [IntegerDigits[n, 2]];
    Array[A080541, 100] (* Paolo Xausa, May 13 2025 *)
  • Python
    def A080541(n): return ((n&(m:=1< 1 else n  # Chai Wah Wu, Jan 22 2023
  • R
    maxlevel <- 6 # by choice
    a <- 1:3
    for(m in 1:maxlevel) for(k in 0:(2^(m-1)-1)){
    a[2^(m+1)       + 2*k    ] = 2*a[2^m           + k]
    a[2^(m+1)       + 2*k + 1] = 2*a[2^m + 2^(m-1) + k]
    a[2^(m+1) + 2^m + 2*k    ] = 2*a[2^m           + k] + 1
    a[2^(m+1) + 2^m + 2*k + 1] = 2*a[2^m + 2^(m-1) + k] + 1
    }
    a
    # Yosu Yurramendi, Oct 12 2020
    
  • Scheme
    (define (A080541 n) (if (< n 2) n (A003986bi (A053644 n) (+ (* 2 (A053645 n)) (A079944off2 n))))) ;; A003986bi gives the bitwise OR of its two arguments. See A003986.
    ;; Where A079944off2 gives the second most significant bit of n. (Cf. A079944):
    (define (A079944off2 n) (A000035 (floor->exact (/ n (A072376 n)))))
    ;; Antti Karttunen, May 16 2015
    

Formula

From Antti Karttunen, May 16 2015: (Start)
a(1) = 1; for n > 1, a(n) = A053644(n) bitwise_OR (2*A053645(n) + second_most_significant_bit_of(n)). [Here bitwise_OR is a 2-argument function given by array A003986 and second_most_significant_bit_of gives the second most significant bit (0 or 1) of n larger than 1. See A079944.]
Other identities. For all n >= 1:
a(n) = A059893(A080542(A059893(n))).
a(n) = A054429(a(A054429(n))).
(End)
A080542(a(n)) = a(A080542(n)) = n. [A080542 is the inverse permutation.]
From Robert Israel, May 19 2015: (Start)
Let d = floor(log[2](n)). If n >= 3*2^(d-1) then a(n) = 2*n + 1 - 2^(d+1), otherwise a(n) = 2*n - 2^d.
G.f.: 2*x/(x-1)^2 + Sum_{n>=1} x^(2^n)+(2^n-1)*x^(3*2^(n-1)))/(x-1). (End)

A080414 Take the rightmost three binary digits of n (for n<4 padded with leading zeros) and rotate right 1 digit.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Feb 17 2003

Keywords

Examples

			a(2)=a('010')='001'=1; a(3)=a('011')='101'=5; a(4)=a('100')='010'=2; a(5)=a('101')='110'=6;
a(20)=a('10'100')='10'010'=18; a(21)=a('10'101')='10'110'=22.
		

Crossrefs

Programs

  • Mathematica
    r3bd[n_]:=Module[{a,b},{a,b}=Reverse[TakeDrop[IntegerDigits[n,2],-3]];FromDigits[Join[a,RotateRight[b]],2]]; Join[{0,4,1,5},Table[r3bd[n],{n,4,80}]] (* Harvey P. Dale, Jul 30 2021 *)
    LinearRecurrence[{1, 0, 0, 0, 0, 0, 0, 1, -1}, {0, 4, 1, 5, 2, 6, 3, 7, 8}, 73] (* Georg Fischer, Jul 03 2025 *)
  • Python
    def A080414(n): return ((n&6)>>1)+((n&1)<<2)+(n&-8) # Chai Wah Wu, Jan 21 2023

Formula

For n>7: a(n) = 8*floor(n/8) + a(n mod 8).
A permutation of natural numbers with inverse A080413: A080413(a(n))=n, a(A080413(n))=n.
a(a(n))=A080413(n), A080413(A080413(n))=a(n), a(a(a(n)))=n.
Showing 1-3 of 3 results.