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

A080782 a(1)=1, a(n)=a(n-1)-1 if n is already in the sequence, a(n)=a(n-1)+2 otherwise.

Original entry on oeis.org

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

Views

Author

Benoit Cloitre, Mar 07 2003

Keywords

Comments

Permutation of the integers: exchange trisections starting with 2 and 3.
a(a(n)) = n. - Reinhard Zumkeller, Oct 29 2004

Crossrefs

Programs

  • Mathematica
    Array[#+Mod[#+1,3]&,70,0] (* or *) LinearRecurrence[{1,0,1,-1},{1,3,2,4},70] (* Harvey P. Dale, Mar 29 2013 *)
    {#,#+1,#-1}[[Mod[#,3,1]]]&/@Range[99] (* Federico Provvedi, May 15 2021 *)

Formula

a(n) = A064429(n-1) + 1.
a(n) - n is periodic with period 3.
G.f.: x*(1+2*x-x^2+x^3)/(1-x-x^3+x^4). - Jaume Oliver Lafont, Mar 24 2009
a(0)=1, a(1)=3, a(2)=2, a(3)=4, a(n)=a(n-1)+0*a(n-2)+a(n-3)-a(n-4). - Harvey P. Dale, Mar 29 2013
a(n) = n + (2/sqrt(3))*sin(2*(n+2)*Pi/3). - Wesley Ivan Hurt, Sep 26 2017
From Guenther Schrack, Oct 23 2019: (Start)
a(n) = a(n-3) + 3 with a(1) = 1, a(2) = 3, a(3) = 2 for n > 3.
a(n) = n - (w^(2*n)*(2 + w) + w^n*(1 - w))/3 where w = (-1 + sqrt(-3))/2. (End)
Sum_{n>=1} (-1)^(n+1)/a(n) = 2*Pi/(3*sqrt(3)) - log(2)/3. - Amiram Eldar, Jan 31 2023
From Charles L. Hohn, Sep 03 2024: (Start)
a(n) = n-1+n%3.
a(n) = A375336(n-2, 1) for n >= 6. (End)

A092486 Take natural numbers, exchange first and third quadrisection.

Original entry on oeis.org

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

Views

Author

Ralf Stephan, Apr 04 2004

Keywords

Crossrefs

Programs

  • Mathematica
    Flatten[Partition[Range[80],4]/.{a_,b_,c_,d_}->{c,b,a,d}] (* Harvey P. Dale, Aug 12 2012 *)
  • PARI
    { f="b092486.txt"; for (n=0, 5000, a0=4*n + 3; a1=a0 - 1; a2=a1 - 1; a3=a0 + 1; write(f, 4*n, " ", a0); write(f, 4*n+1, " ", a1); write(f, 4*n+2, " ", a2); write(f, 4*n+3, " ", a3); ); } \\ Harry J. Smith, Jun 21 2009

Formula

G.f.: (3-4*x+3*x^2)/((1+x^2)*(1-x)^2).
a(4n) = 4n+3, a(4n+1) = 4n+2, a(4n+2) = 4n+1, a(4n+3) = 4n+4.
a(n) = n+1+i^n+(-i)^n, where i is the imaginary unit. - Bruno Berselli, Feb 08 2011
From Wesley Ivan Hurt, May 09 2021: (Start)
a(n) = 2*a(n-1)-2*a(n-2)+2*a(n-3)-a(n-4).
a(n) = 1 + n + 2*cos(n*Pi/2). (End)
Sum_{n>=0} (-1)^n/a(n) = log(2) (A002162). - Amiram Eldar, Nov 28 2023

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

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Feb 17 2003

Keywords

Examples

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

Crossrefs

Programs

  • Mathematica
    LinearRecurrence[{1, 0, 0, 0, 0, 0, 0, 1, -1}, {0, 2, 4, 6, 1, 3, 5, 7, 8}, 73] (* Georg Fischer, Jul 03 2025 *)
  • Python
    def A080413(n): return ((n&3)<<1)+bool(n&4)+(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 = A080414: A080414(a(n))=n, a(A080414(n))=n.
a(a(n))=A080414(n), A080414(A080414(n))=a(n), a(a(a(n)))=n.

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.

A292576 Permutation of the natural numbers partitioned into quadruples [4k-1, 4k-3, 4k-2, 4k], k > 0.

Original entry on oeis.org

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

Views

Author

Guenther Schrack, Sep 19 2017

Keywords

Comments

Partition the natural number sequence into quadruples starting with (1,2,3,4); swap the second and third elements, then swap the first and the second element; repeat for all quadruples.

Crossrefs

Inverse: A056699(n+1) - 1 for n > 0.
Sequence of fixed points: A008586(n) for n > 0.
Subsequences:
elements with odd index: A042964(A103889(n)) for n > 0.
elements with even index: A042948(n) for n > 0.
odd elements: A166519(n) for n>0.
indices of odd elements: A042963(n) for n > 0.
even elements: A005843(n) for n>0.
indices of even elements: A014601(n) for n > 0.
Sum of pairs of elements:
a(n+2) + a(n) = A163980(n+1) = A168277(n+2) for n > 0.
Difference between pairs of elements:
a(n+2) - a(n) = (-1)^A011765(n+3)*A091084(n+1) for n > 0.
Compound relations:
a(n) = A284307(n+1) - 1 for n > 0.
a(n+2) - 2*a(n+1) + a(n) = (-1)^A011765(n)*A132400(n+1) for n > 0.
Compositions:
a(n) = A116966(A080412(n)) for n > 0.
a(A284307(n)) = A256008(n) for n > 0.
a(A042963(n)) = A166519(n-1) for n > 0.
A256008(a(n)) = A056699(n) for n > 0.

Programs

  • MATLAB
    a = [3 1 2 4]; % Generate b-file
    max = 10000;
    for n := 5:max
       a(n) = a(n-4) + 4;
    end;
    
  • PARI
    for(n=1, 10000, print1(n + ((-1)^(n*(n-1)/2)*(2 - (-1)^n) - (-1)^n)/2, ", "))

Formula

a(1)=3, a(2)=1, a(3)=2, a(4)=4, a(n) = a(n-4) + 4 for n > 4.
O.g.f.: (2*x^3 + x^2 - 2*x + 3)/(x^5 - x^4 - x + 1).
a(n) = n + ((-1)^(n*(n-1)/2)*(2-(-1)^n) - (-1)^n)/2.
a(n) = n + (cos(n*Pi/2) - cos(n*Pi) + 3*sin(n*Pi/2))/2.
a(n) = n + n mod 2 + (ceiling(n/2)) mod 2 - 2*(floor(n/2) mod 2).
Linear recurrence: a(n) = a(n-1) + a(n-4) - a(n-5) for n>5.
First Differences, periodic: (-2, 1, 2, 3), repeat; also (-1)^A130569(n)*A068073(n+2) for n > 0.

A298364 Permutation of the natural numbers partitioned into quadruples [4k-2, 4k-1, 4k-3, 4k] for k > 0.

Original entry on oeis.org

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

Views

Author

Guenther Schrack, Jan 18 2018

Keywords

Comments

Partition the natural number sequence into quadruples starting with (1,2,3,4); swap the first and second elements, then swap the second and third elements; repeat for all quadruples.

Crossrefs

Inverse: A292576.
Sequence of fixed points: A008586(n) for n > 0.
First differences: (-1)^floor(n^2/4)*A068073(n-1) for n > 0.
Subsequences:
elements with odd index: A042963(A103889(n)) for n > 0.
elements with even index A014601(n) for n > 0.
odd elements: A166519(n-1) for n > 0.
indices of odd elements: A042964(n) for n > 0.
even elements: A005843(n) for n > 0.
indices of even elements: A042948(n) for n > 0.
Other similar permutations: A116966, A284307, A292576.

Programs

  • MATLAB
    a = [2 3 1 4];
    max = 10000;    % Generation of b-file.
    for n := 5:max
       a(n) = a(n-4) + 4;
    end;
    
  • Mathematica
    Nest[Append[#, #[[-4]] + 4] &, {2, 3, 1, 4}, 63] (* or *)
    Array[# + ((-1)^# + ((-1)^(# (# - 1)/2)) (1 - 2 (-1)^#))/2 &, 67] (* Michael De Vlieger, Jan 23 2018 *)
    LinearRecurrence[{1,0,0,1,-1},{2,3,1,4,6},70] (* Harvey P. Dale, Dec 12 2018 *)
  • PARI
    for(n=1, 100, print1(n + ((-1)^n + ((-1)^(n*(n-1)/2))*(1 - 2*(-1)^n))/2, ", "))

Formula

O.g.f.: (3*x^3 - 2*x^2 + x + 2)/(x^5 - x^4 - x - 1).
a(1) = 2, a(2) = 3, a(3) = 1, a(4) = 4, a(n) = a(n-4) + 4 for n > 4.
a(n) = n + ((-1)^n + ((-1)^(n*(n-1)/2))*(1 - 2*(-1)^n))/2.
a(n) = n + (cos(n*Pi) - cos(n*Pi/2) + 3*sin(n*Pi/2))/2.
a(n) = 2*floor((n+1)/2) - 4*floor((n+1)/4) + floor(n/2) + 2*floor(n/4).
a(n) = n + (-1)^floor((n-1)^2/4)*A140081(n) for n > 0.
a(n) = A056699(n+1) - 1, n > 0.
a(n+2) = A168269(n+1) - a(n), n > 0.
a(n+2) = a(n) + (-1)^floor((n+1)^2/4)*A132400(n+2) for n > 0.
Linear recurrence: a(n) = a(n-1) + a(n-4) - a(n-5) for n > 5.
First differences: periodic, (1, -2, 3, 2) repeat.
Compositions:
a(n) = A080412(A116966(n-1)) for n > 0.
a(n) = A284307(A256008(n)) for n > 0.
a(A067060(n)) = A133256(n) for n > 0.
A116966(a(n+1)-1) = A092486(n) for n >= 0.
A056699(a(n)) = A256008(n) for n > 0.

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

A271830 Expansion of (3 - 4*x + 3*x^2 + x^4)/((1 - x)^2*(1 + x^2 + x^4)).

Original entry on oeis.org

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

Views

Author

Ilya Gutkovskiy, Apr 18 2016

Keywords

Comments

Permutation of the positive integers, with 6k+1 and 6k+3 swapped for every k.

Crossrefs

Programs

  • Magma
    [3 - n + 4*Floor(n/6) + 2*Floor((n+1)/6) + 2*Floor((n+2)/6) + 4*Floor((n+3)/6) : n in [0..100]]; // Wesley Ivan Hurt, Apr 20 2016
  • Maple
    A271830:=n->3-n+4*floor(n/6)+2*floor((n+1)/6)+2*floor((n+2)/6)+4*floor((n+3)/6): seq(A271830(n), n=0..150); # Wesley Ivan Hurt, Apr 20 2016
  • Mathematica
    CoefficientList[Series[(3 - 4 x + 3 x^2 + x^4)/((1 - x)^2 (1 + x^2 + x^4)), {x, 0, 75}], x]
    LinearRecurrence[{2, -2, 2, -2, 2, -1}, {3, 2, 1, 4, 5, 6}, 75]
  • PARI
    x='x+O('x^99); Vec((3-4*x+3*x^2+x^4)/((1-x)^2*(1+x^2+x^4))) \\ Altug Alkan, Apr 18 2016
    

Formula

G.f.: (3 - 4*x + 3*x^2 + x^4)/((1 - x)^2*(1 + x^2 + x^4)).
a(n) = 2*a(n-1) - 2*a(n-2) + 2*a(n-3) - 2*a(n-4) + 2*a(n-5) - a(n-6).
a(n) = 3 - n + 4*floor(n/6) + 2*floor((n+1)/6) + 2*floor((n+2)/6) + 4*floor((n+3)/6). - Vaclav Kotesovec, Apr 19 2016

A317613 Permutation of the nonnegative integers: lodumo_4 of A047247.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Write n in base 8, then apply the following substitution to the rightmost digit: '0'->'2, '1'->'3', and vice versa. Convert back to decimal.
A self-inverse permutation: a(a(n)) = n.
Array whose columns are, in this order, A047463, A047621, A047451 and A047522, read by rows.

Examples

			a(25) = a('3'1') = '3'3' = 27.
a(26) = a('3'2') = '3'0' = 24.
a(27) = a('3'3') = '3'1' = 25.
a(28) = a('3'4') = '3'4' = 28.
a(29) = a('3'5') = '3'5' = 29.
The sequence as array read by rows:
  A047463, A047621, A047451, A047522;
        2,       3,       0,       1;
        4,       5,       6,       7;
       10,      11,       8,       9;
       12,      13,      14,      15;
       18,      19,      16,      17;
       20,      21,      22,      23;
       26,      27,      24,      25;
       28,      29,      30,      31;
  ...
		

Crossrefs

Programs

  • Magma
    m:=100; R:=PowerSeriesRing(Integers(), m); Coefficients(R!((x^7+x^5+3*x^3-2*x^2-x+2)/((1-x)^2*(x^6+x^4+ x^2+1)))); // G. C. Greubel, Sep 25 2018
  • Mathematica
    Table[(4*(Floor[1/4 Mod[2*n + 4, 8]] - Floor[1/4 Mod[n + 2, 8]]) + 2*n)/2, {n, 0, 100}]
    f[n_] := Block[{id = IntegerDigits[n, 8]}, FromDigits[ Join[Most@ id /. {{} -> {0}}, {id[[-1]] /. {0 -> 2, 1 -> 3, 2 -> 0, 3 -> 1}}], 8]]; Array[f, 67, 0] (* or *)
    CoefficientList[ Series[(x^7 + x^5 + 3x^3 - 2x^2 - x + 2)/((x - 1)^2 (x^6 + x^4 + x^2 + 1)), {x, 0, 70}], x] (* or *)
    LinearRecurrence[{2, -2, 2, -2, 2, -2, 2, -1}, {2, 3, 0, 1, 4, 5, 6, 7}, 70] (* Robert G. Wilson v, Aug 01 2018 *)
  • Maxima
    makelist((4*(floor(mod(2*n + 4, 8)/4) - floor(mod(n + 2, 8)/4)) + 2*n)/2, n, 0, 100);
    
  • PARI
    my(x='x+O('x^100)); Vec((x^7+x^5+3*x^3-2*x^2-x+2)/((1-x)^2*(x^6+x^4+ x^2+1))) \\ G. C. Greubel, Sep 25 2018
    

Formula

a(n) = 2*a(n-1) - 2*a(n-2) + 2*a(n-3) - 2*a(n-4) + 2*a(n-5) - 2*a(n-6) + 2*a(n-7) - a(n-8), n > 7.
a(n) = (4*(floor(((2*n + 4) mod 8)/4) - floor(((n + 2) mod 8)/4)) + 2*n)/2.
a(n) = lod_4(A047247(n+1)).
a(4*n) = A047463(n+1).
a(4*n+1) = A047621(n+1).
a(4*n+2) = A047451(n+1).
a(4*n+3) = A047522(n+1).
a(A042948(n)) = A047596(n+1).
a(A042964(n+1)) = A047551(n+1).
G.f.: (x^7 + x^5 + 3*x^3 - 2*x^2 - x + 2)/((x-1)^2 * (x^2+1) * (x^4+1)).
E.g.f.: x*exp(x) + cos(x) + sin(x) + cos(x/sqrt(2))*cosh(x/sqrt(2)) + (sqrt(2)*cos(x/sqrt(2)) - sin(x/sqrt(2)))*sinh(x/sqrt(2)).
a(n+8) = a(n) + 8 . - Philippe Deléham, Mar 09 2023
Sum_{n>=3} (-1)^(n+1)/a(n) = 1/6 + log(2). - Amiram Eldar, Mar 12 2023

A336434 Square array read by descending antidiagonals T(n,k): In the binary expansion of n, reverse the order of the bits in the same position as the active bits in A057716(k).

Original entry on oeis.org

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

Views

Author

Davis Smith, Jul 21 2020

Keywords

Comments

T(n,k) is the swapping of the positions of the bits in n according to the active bits in K, where K = A057716(k). The bit in the same position as the first active bit in K switches positions with the bit in the same position as the last active bit in K, the bit in the same position as the second active bit in K switches with the one in the same as the second to last position, and so on until all have swapped (without repeating).
Any sequence, f, of the form "reverse the order of the a-th, b-th, ... and z-th bits in n" can be expressed as f(n) = T(n,k), where A057716(k) = 2^a + 2^b + ... 2^z. As a result, this operation combines 1 or more bit-swapping operations, which could be useful for bit-manipulation in computer programming.

Examples

			The binary expansion of 18 is 10010_2 and the active bits in the binary expansion of A057716(22) = 27 = 11011_2 are 0, 1, 3, and 4. So, to get T(18,22), we swap the 0th and 4th bits and then the 1st and 3rd bits, which gives us T(18,22) = 9.
Square array T(n,k) begins:
  \k   1   2   3   4   5   6   7   8   9  10 ...
  n\
   1|  2   4   1   4   8   1   8   1   8   1 ...
   2|  1   2   4   2   2   8   2   2   2   8 ...
   3|  3   6   5   6  10   9  10   3  10   9 ...
   4|  4   1   2   1   4   4   4   8   4   4 ...
   5|  6   5   3   5  12   5  12   9  12   5 ...
   6|  5   3   6   3   6  12   6  10   6  12 ...
   7|  7   7   7   7  14  13  14  11  14  13 ...
   8|  8   8   8   8   1   2   1   4   1   2 ...
   9| 10  12   9  12   9   3   9   5   9   3 ...
  10|  9  10  12  10   3  10   3   6   3  10 ...
		

Crossrefs

Programs

  • PARI
    A336434(n,k)={my(K=k+#binary(k+#binary(k)), P=select(Z->bittest(K,Z),[0..#binary(K)-1]), Q1=P[1..floor(#P/2)],Q2=Vecrev(P)[1..floor(#P/2)], Sum=vecsum(apply(p->if(bittest(n,Q1[p])!=bittest(n,Q2[p]), bitor(shift(1,Q1[p]),shift(1,Q2[p]))), [1..floor(#P/2)])));bitxor(n,Sum)}

Formula

T(n,k) = A003987(n, Sum_{m=1..floor(M/2)} A003987(A030308(n,A133457(K,m)), A030308(n,A133457(K,M - (m - 1))))* (2^A133457(K,m) + 2^A133457(K,M - (m - 1)))), where K = A057716(k) and M = A000120(A057716(k)).
When A057716(k) = 2^A070939(n) - 1, T(n,k) = A030101(n).
When A057716(k) = 2^(A070939(n) - 1) - 1, T(n,k) = A059893(n).
Showing 1-10 of 12 results. Next