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

A268717 Permutation of natural numbers: a(0) = 0, a(n) = A003188(1+A006068(n-1)), where A003188 is binary Gray code and A006068 is its inverse.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Feb 12 2016

Keywords

Crossrefs

Inverse: A268718.
Row 1 and column 1 of array A268715 (without the initial zero).
Row 1 of array A268820.
Cf. A092246 (fixed points).
Cf. A268817 ("square" of this permutation).
Cf. A268821 ("shifted square"), A268823 ("shifted cube") and also A268825, A268827 and A268831 ("shifted higher powers").

Programs

Formula

a(n) = A003188(A066194(n)) = A003188(1+A006068(n-1)).
Other identities. For all n >= 0:
A101080(n,a(n+1)) = 1. [The Hamming distance between n and a(n+1) is always one.]
A268726(n) = A000523(A003987(n, a(n+1))). [A268726 gives the index of the toggled bit.]
From Alan Michael Gómez Calderón, May 29 2025: (Start)
a(2*n) = (2*n-1) XOR (2-A010060(n-1)) for n >= 1;
a(n) = (A268718(n-1)-1) XOR (A171977(n-1)+1) for n >= 2. (End)

A302846 Interleave the Gray-coded X and Y-coordinates of 2-dimensional Hilbert's curve in alternate bit-positions: a(n) = A000695(A003188(A059253(n))) + 2*A000695(A003188(A059252(n))).

Original entry on oeis.org

0, 1, 3, 2, 10, 8, 9, 11, 15, 13, 12, 14, 6, 7, 5, 4, 20, 22, 23, 21, 17, 16, 18, 19, 27, 26, 24, 25, 29, 31, 30, 28, 60, 62, 63, 61, 57, 56, 58, 59, 51, 50, 48, 49, 53, 55, 54, 52, 36, 37, 39, 38, 46, 44, 45, 47, 43, 41, 40, 42, 34, 35, 33, 32, 160, 162, 163, 161, 165, 164, 166, 167, 175, 174, 172, 173, 169, 171, 170, 168, 136
Offset: 0

Views

Author

Antti Karttunen, Apr 14 2018

Keywords

Comments

Like in binary Gray code A003188, also in this permutation the binary expansions of a(n) and a(n+1) differ always by just a single bit-position, that is, A000120(A003987(a(n),a(n+1))) = 1 for all n >= 0. Here A003987 computes bitwise-XOR of its two arguments.
When composed with A052330 this gives A302781.

Crossrefs

Cf. A302845 (inverse permutation).
Cf. also A003188, A163252, A300838 for other permutations satisfying the same condition.

Programs

  • PARI
    A064706(n) = bitxor(n, n>>2);
    A057300(n) = { my(t=1,s=0); while(n>0, if(1==(n%4),n++,if(2==(n%4),n--)); s += (n%4)*t; n >>= 2; t <<= 2); (s); };
    A163356(n) = if(!n,n,my(i = (#binary(n)-1)\2, f = 4^i, d = (n\f)%4, r = (n%f)); (((((2+(i%2))^d)%5)-1)*f) + if(3==d,f-1-A163356(r),A057300(A163356(r))));
    A302846(n) = A064706(A163356(n));

Formula

a(n) = A064706(A163356(n)) = A003188(A302844(n)).

A268718 Permutation of natural numbers: a(0) = 0, a(n) = 1 + A003188(A006068(n)-1), where A003188 is binary Gray code and A006068 is its inverse.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Feb 12 2016

Keywords

Crossrefs

Inverse: A268717.
Row 1 of array A268830.
Cf. A092246 (fixed points).
Cf. A268818 ("square" of this permutation).
Cf. A268822 ("shifted square"), A268824 ("shifted cube") and also A268826, A268828 and A268832 (higher "shifted powers").

Programs

  • Mathematica
    {0}~Join~Table[1 + BitXor[#, Floor[#/2]] &[BitXor @@ Table[Floor[n/2^m], {m, 0, Floor[Log[2, n]]}] - 1], {n, 81}] (* Michael De Vlieger, Feb 29 2016, after Jean-François Alcover at A006068 and Robert G. Wilson v at A003188 *)
  • PARI
    a003188(n)=bitxor(n, n>>1);
    a006068(n)= {
        my( s=1, ns );
        while ( 1,
            ns = n >> s;
            if ( 0==ns, break() );
            n = bitxor(n, ns);
            s <<= 1;
        );
        return (n);
    } \\ by Joerg Arndt
    a(n)=if(n==0, 0, 1 + a003188(a006068(n) - 1)); \\ Indranil Ghosh, Jun 07 2017
    
  • Python
    def a003188(n): return n^(n>>1)
    def a006068(n):
        s=1
        while True:
            ns=n>>s
            if ns==0: break
            n=n^ns
            s<<=1
        return n
    def a(n): return 0 if n==0 else 1 + a003188(a006068(n) - 1) # Indranil Ghosh, Jun 07 2017
  • Scheme
    (define (A268718 n) (if (zero? n) n (A105081 (A006068 n))))
    

Formula

a(0) = 0, and for n >= 1, a(n) = A105081(A006068(n)) = 1 + A003188(A006068(n)-1).
Other identities. For all n >= 1:
a(A128309(n)) = A128309(n)+2. [Maps any even odious number to that number + 2.]
From Alan Michael Gómez Calderón, May 29 2025: (Start)
a(n) - 1 = A268717(n+1) XOR (A171977(n)+1) for n >= 1;
a(2*n-1) - 1 = (2-A010060(n-1)) XOR (A166519(n-1)-1) for n >= 1;
a(2*n) - 1 = (a(2*(n+1)-1)-1) XOR 2^A277822(n) for n >= 1. (End)

A268820 Square array A(r,c): A(0,c) = c, A(r,0) = 0, A(r>=1,c>=1) = A003188(1+A006068(A(r-1,c-1))) = A268717(1+A(r-1,c-1)), read by descending antidiagonals as A(0,0), A(0,1), A(1,0), A(0,2), A(1,1), A(2,0), ...

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Feb 14 2016

Keywords

Examples

			The top left [0 .. 16] x [0 .. 19] section of the array:
0, 1, 2, 3, 4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
0, 1, 3, 6, 2, 12,  4,  7,  5, 24,  8, 11,  9, 13, 15, 10, 14, 48, 16, 19
0, 1, 3, 2, 7,  6, 13, 12,  5,  4, 25, 24,  9,  8, 15, 14, 11, 10, 49, 48
0, 1, 3, 2, 6,  5,  7, 15, 13,  4, 12, 27, 25,  8, 24, 14, 10,  9, 11, 51
0, 1, 3, 2, 6,  7,  4,  5, 14, 15, 12, 13, 26, 27, 24, 25, 10, 11,  8,  9
0, 1, 3, 2, 6,  7,  5, 12,  4, 10, 14, 13, 15, 30, 26, 25, 27, 11,  9, 24
0, 1, 3, 2, 6,  7,  5,  4, 13, 12, 11, 10, 15, 14, 31, 30, 27, 26,  9,  8
0, 1, 3, 2, 6,  7,  5,  4, 12, 15, 13,  9, 11, 14, 10, 29, 31, 26, 30,  8
0, 1, 3, 2, 6,  7,  5,  4, 12, 13, 14, 15,  8,  9, 10, 11, 28, 29, 30, 31
0, 1, 3, 2, 6,  7,  5,  4, 12, 13, 15, 10, 14, 24,  8, 11,  9, 20, 28, 31
0, 1, 3, 2, 6,  7,  5,  4, 12, 13, 15, 14, 11, 10, 25, 24,  9,  8, 21, 20
0, 1, 3, 2, 6,  7,  5,  4, 12, 13, 15, 14, 10,  9, 11, 27, 25,  8, 24, 23
0, 1, 3, 2, 6,  7,  5,  4, 12, 13, 15, 14, 10, 11,  8,  9, 26, 27, 24, 25
0, 1, 3, 2, 6,  7,  5,  4, 12, 13, 15, 14, 10, 11,  9, 24,  8, 30, 26, 25
0, 1, 3, 2, 6,  7,  5,  4, 12, 13, 15, 14, 10, 11,  9,  8, 25, 24, 31, 30
0, 1, 3, 2, 6,  7,  5,  4, 12, 13, 15, 14, 10, 11,  9,  8, 24, 27, 25, 29
0, 1, 3, 2, 6,  7,  5,  4, 12, 13, 15, 14, 10, 11,  9,  8, 24, 25, 26, 27
		

Crossrefs

Inverses of these permutations can be found in table A268830.
Row 0: A001477, Row 1: A268717, Row 2: A268821, Row 3: A268823, Row 4: A268825, Row 5: A268827, Row 6: A268831, Row 7: A268933.
Rows converge towards A003188, which is also the main diagonal.
Cf. array A268715 (can be extracted from this one).
Cf. array A268833 (shows related Hamming distances with regular patterns).

Programs

  • Mathematica
    A003188[n_]:=BitXor[n, Floor[n/2]]; A006068[n_]:=If[n<2, n, Block[{m=A006068[Floor[n/2]]}, 2m + Mod[Mod[n,2] + Mod[m, 2], 2]]]; a[r_, 0]:= 0; a[0, c_]:=c; a[r_, c_]:= A003188[1 + A006068[a[r - 1, c - 1]]]; Table[a[c, r - c], {r, 0, 15}, {c, 0, r}] //Flatten (* Indranil Ghosh, Apr 02 2017 *)
  • PARI
    A003188(n) = bitxor(n, n\2);
    A006068(n) = if(n<2, n, {my(m = A006068(n\2)); 2*m + (n%2 + m%2)%2});
    a(r, c) = if(r==0, c, if(c==0, 0, A003188(1 + A006068(a(r - 1, c - 1)))));
    for(r=0, 15, for(c=0, r, print1(a(c, r - c),", "); ); print(); ); \\ Indranil Ghosh, Apr 02 2017
    
  • Python
    def A003188(n): return n^(n//2)
    def A006068(n):
        if n<2: return n
        else:
            m=A006068(n//2)
            return 2*m + (n%2 + m%2)%2
    def a(r, c): return c if r<1 else 0 if c<1 else A003188(1 + A006068(a(r - 1, c - 1)))
    for r in range(16):
        print([a(c, r - c) for c in range(r + 1)]) # Indranil Ghosh, Apr 02 2017
  • Scheme
    (define (A268820 n) (A268820bi (A002262 n) (A025581 n)))
    (define (A268820bi row col) (cond ((zero? row) col) ((zero? col) 0) (else (A268717 (+ 1 (A268820bi (- row 1) (- col 1)))))))
    (define (A268820bi row col) (cond ((zero? row) col) ((zero? col) 0) (else (A003188 (+ 1 (A006068 (A268820bi (- row 1) (- col 1))))))))
    

Formula

For row zero: A(0,k) = k, for column zero: A(n,0) = 0, and in other cases: A(n,k) = A003188(1+A006068(A(n-1,k-1)))
Other identities. For all n >= 0:
A(n,n) = A003188(n).
A(A006068(n),A006068(n)) = n.

A268715 Square array A(i,j) = A003188(A006068(i) + A006068(j)), read by antidiagonals as A(0,0), A(0,1), A(1,0), A(0,2), A(1,1), A(2,0), ...

Original entry on oeis.org

0, 1, 1, 2, 3, 2, 3, 6, 6, 3, 4, 2, 5, 2, 4, 5, 12, 7, 7, 12, 5, 6, 4, 15, 6, 15, 4, 6, 7, 7, 13, 13, 13, 13, 7, 7, 8, 5, 4, 12, 9, 12, 4, 5, 8, 9, 24, 12, 5, 11, 11, 5, 12, 24, 9, 10, 8, 27, 4, 14, 10, 14, 4, 27, 8, 10, 11, 11, 25, 25, 10, 15, 15, 10, 25, 25, 11, 11, 12, 9, 8, 24, 29, 14, 12, 14, 29, 24, 8, 9, 12, 13, 13, 24, 9, 31, 31, 13, 13, 31, 31, 9, 24, 13, 13
Offset: 0

Views

Author

Antti Karttunen, Feb 12 2016

Keywords

Comments

Each row n is row A006068(n) of array A268820 without its A006068(n) initial terms.

Examples

			The top left [0 .. 15] x [0 .. 15] section of the array:
   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15
   1,  3,  6,  2, 12,  4,  7,  5, 24,  8, 11,  9, 13, 15, 10, 14
   2,  6,  5,  7, 15, 13,  4, 12, 27, 25,  8, 24, 14, 10,  9, 11
   3,  2,  7,  6, 13, 12,  5,  4, 25, 24,  9,  8, 15, 14, 11, 10
   4, 12, 15, 13,  9, 11, 14, 10, 29, 31, 26, 30,  8, 24, 27, 25
   5,  4, 13, 12, 11, 10, 15, 14, 31, 30, 27, 26,  9,  8, 25, 24
   6,  7,  4,  5, 14, 15, 12, 13, 26, 27, 24, 25, 10, 11,  8,  9
   7,  5, 12,  4, 10, 14, 13, 15, 30, 26, 25, 27, 11,  9, 24,  8
   8, 24, 27, 25, 29, 31, 26, 30, 17, 19, 22, 18, 28, 20, 23, 21
   9,  8, 25, 24, 31, 30, 27, 26, 19, 18, 23, 22, 29, 28, 21, 20
  10, 11,  8,  9, 26, 27, 24, 25, 22, 23, 20, 21, 30, 31, 28, 29
  11,  9, 24,  8, 30, 26, 25, 27, 18, 22, 21, 23, 31, 29, 20, 28
  12, 13, 14, 15,  8,  9, 10, 11, 28, 29, 30, 31, 24, 25, 26, 27
  13, 15, 10, 14, 24,  8, 11,  9, 20, 28, 31, 29, 25, 27, 30, 26
  14, 10,  9, 11, 27, 25,  8, 24, 23, 21, 28, 20, 26, 30, 29, 31
  15, 14, 11, 10, 25, 24,  9,  8, 21, 20, 29, 28, 27, 26, 31, 30
		

Crossrefs

Main diagonal: A001969.
Row 0, column 0: A001477.
Row 1, column 1: A268717.
Antidiagonal sums: A268837.
Cf. A268719 (the lower triangular section).
Cf. also A268725.

Programs

Formula

A(i,j) = A003188(A006068(i) + A006068(j)) = A003188(A268714(i,j)).
A(row,col) = A268820(A006068(row), (A006068(row)+col)).

A300838 Permutation of nonnegative integers: a(n) = A057300(A003188(n)).

Original entry on oeis.org

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

Views

Author

Antti Karttunen and Peter Munn, Apr 15 2018

Keywords

Comments

Like in binary Gray code A003188, also in this permutation the binary expansions of a(n) and a(n+1) differ always by just a single bit-position, that is, A000120(A003987(a(n),a(n+1))) = 1 for all n >= 0. Here A003987 computes bitwise-XOR of its two arguments. This is true for any composition P(A003188(n)), where P is a permutation that permutes the bit-positions of binary expansion of n in some way.
When composed with A052330 this gives a divisor-or-multiple permutation similar to A207901 and A302781.

Crossrefs

Cf. A300839 (inverse permutation).
Cf. also A003188, A163252, A302846 for other permutations satisfying the same condition.

Programs

  • PARI
    A003188(n) = bitxor(n, n>>1);
    A057300(n) = { my(t=1, s=0); while(n>0,  if(1==(n%4),n++,if(2==(n%4),n--)); s += (n%4)*t; n >>= 2; t <<= 2); (s); };
    A300838(n) = A057300(A003188(n));

Formula

a(n) = A057300(A003188(n)).

A055975 First differences of A003188 (decimal equivalent of the Gray Code).

Original entry on oeis.org

1, 2, -1, 4, 1, -2, -1, 8, 1, 2, -1, -4, 1, -2, -1, 16, 1, 2, -1, 4, 1, -2, -1, -8, 1, 2, -1, -4, 1, -2, -1, 32, 1, 2, -1, 4, 1, -2, -1, 8, 1, 2, -1, -4, 1, -2, -1, -16, 1, 2, -1, 4, 1, -2, -1, -8, 1, 2, -1, -4, 1, -2, -1, 64, 1, 2, -1, 4, 1, -2, -1, 8, 1, 2, -1, -4, 1, -2, -1, 16, 1, 2, -1, 4, 1, -2, -1, -8, 1, 2, -1, -4, 1, -2, -1, -32, 1, 2, -1, 4
Offset: 1

Views

Author

Alford Arnold, Jul 22 2000

Keywords

Comments

Multiplicative with a(2^e) = 2^e, a(p^e) = (-1)^((p^e-1)/2) otherwise. - Mitch Harris, May 17 2005
a(A091072(n)) > 0; a(A091067(n)) < 0. - Reinhard Zumkeller, Apr 28 2012
In the binary representation of n, clear everything left of the least significant 1 bit, and negate if the bit left of it was set originally. - Ralf Stephan, Aug 23 2013
This sequence is the trace of n in the minimal alternating binary representation of n (defined at A256696). - Clark Kimberling, Apr 07 2015

Examples

			Since A003188 is 0, 1,  3, 2, 6,  7,  5, 4, 12, 13, 15, 14, 10, ...,
sequence begins  1, 2, -1, 4, 1, -2, -1, 8,  1,  2, -1,  4, ... .
		

Crossrefs

Cf. A003188, A006519 (unsigned), A007814.
MASKTRANSi transform of A053644 (conjectural).

Programs

  • Haskell
    a055975 n = a003188 n - a003188 (n-1)
    a055975_list = zipWith (-) (tail a003188_list) a003188_list
    -- Reinhard Zumkeller, Apr 28 2012
    
  • Maple
    nmax:=100: for p from 0 to ceil(simplify(log[2](nmax))) do for n from 1 to ceil(nmax/(p+2)) do a((2*n-1)*2^p) := (-1)^(n+1)*2^p od: od: seq(a(n), n=1..nmax); # Johannes W. Meijer, Jan 27 2013
  • Mathematica
    f[n_]:=BitXor[n,Floor[n/2]];Differences[Array[f,120,0]] (* Harvey P. Dale, Jul 18 2011, applying Robert G. Wilson v's program from A003188 *)
  • PARI
    a(n)=((-1)^((n/2^valuation(n,2)-1)/2)*2^valuation(n,2)) \\ Ralf Stephan
    
  • Python
    def A055975(n): return (n^(n>>1))-((n-1)^(n-1>>1)) # Chai Wah Wu, Jun 29 2022

Formula

a(2n) = 2a(n), a(2n+1) = (-1)^n. G.f. sum(k>=0, 2^k*t/(1+t^2), t=x^2^k). a(n) = 2^A007814(n) * (-1)^((n/2^A007814(n)-1)/2). - Ralf Stephan, Oct 29 2003
a((2*n-1)*2^p) = (-1)^(n+1)*2^p, p >= 0. - Johannes W. Meijer, Jan 27 2013

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Sep 05 2000

A064706 Square of permutation defined by A003188.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Oct 13 2001

Keywords

Comments

Inverse of sequence A064707 considered as a permutation of the nonnegative integers.
Not the same as A100282: a(n) = A100282(n) = A100280(A100280(n)) only for n < 64. - Reinhard Zumkeller, Nov 11 2004

Crossrefs

Cf. A064707 (inverse), A165211 (mod 2).
Cf. also A054238, A163233, A302846.

Programs

  • MATLAB
    A = 1; for i = 1:7 B = A(end:-1:1); A = [A (B + length(A))]; end A(A) - 1
    
  • Mathematica
    Array[BitXor[#, Floor[#/4]] &, 72, 0] (* Michael De Vlieger, Apr 14 2018 *)
  • PARI
    a(n)=bitxor(n,n\4)
    
  • PARI
    { for (n=0, 1000, write("b064706.txt", n, " ", bitxor(n, n\4)) ) } \\ Harry J. Smith, Sep 22 2009
    
  • Python
    def A064706(n): return n^ n>>2 # Chai Wah Wu, Jun 29 2022
  • R
    maxn <- 63 # by choice
    b <- c(1,0,0)
    for(n in 4:maxn) b[n] <- b[n-1] - b[n-2] + b[n-3]
    # c(1,b) is A133872
    a <- 1
    for(n in 1:maxn) {
    a[2*n  ] <- 2*a[n] + 1 - b[n]
    a[2*n+1] <- 2*a[n] +     b[n]
    }
    (a <- c(0,a))
    # Yosu Yurramendi, Oct 25 2020
    

Formula

a(n) = A003188(A003188(n)).
a(n) = n XOR floor(n/4), where XOR is binary exclusive OR. - Paul D. Hanna, Oct 25 2004
a(n) = A233280(A180201(n)), n > 0. - Yosu Yurramendi, Apr 05 2017
a(n) = A000695(A003188(A059905(n))) + 2*A000695(A003188(A059906(n))). - Antti Karttunen, Apr 14 2018

Extensions

More terms from David Wasserman, Aug 02 2002

A233280 Permutation of nonnegative integers: a(n) = A003188(A054429(n)).

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Dec 18 2013

Keywords

Comments

This permutation transforms the enumeration system of positive irreducible fractions A071766/A229742 (HCS) into the enumeration system A007305/A047679 (Stern-Brocot), and the enumeration system A245325/A245326 into A162909/A162910 (Bird). - Yosu Yurramendi, Jun 09 2015

Crossrefs

Inverse permutation: A233279.
Similarly constructed permutation pairs: A003188/A006068, A135141/A227413, A232751/A232752, A233275/A233276, A233277/A233278, A193231 (self-inverse).

Programs

  • Python
    from sympy import floor
    def a003188(n): return n^(n>>1)
    def a054429(n): return 1 if n==1 else 2*a054429(floor(n/2)) + 1 - n%2
    def a(n): return 0 if n==0 else a003188(a054429(n)) # Indranil Ghosh, Jun 11 2017
  • R
    maxrow <- 8 # by choice
    a <- 1
    for(m in 0:maxrow) for(k in 0:(2^m-1)){
    a[2^(m+1)+    k] <- a[2^m+      k] + 2^m
    a[2^(m+1)+2^m+k] <- a[2^(m+1)-1-k] + 2^(m+1)
    }
    a
    # Yosu Yurramendi, Apr 05 2017
    
  • Scheme
    (define (A233280 n) (A003188 (A054429 n)))
    ;; Alternative version, based on entangling even & odd numbers with odious and evil numbers:
    (definec (A233280 n) (cond ((< n 2) n) ((even? n) (A000069 (+ 1 (A233280 (/ n 2))))) (else (A001969 (+ 1 (A233280 (/ (- n 1) 2)))))))
    

Formula

a(n) = A003188(A054429(n)).
a(n) = A063946(A003188(n)).
a(n) = A054429(A154436(n)).
a(0)=0, a(1)=1, and otherwise, a(2n) = A000069(1+a(n)), a(2n+1) = A001969(1+a(n)). [A recurrence based on entangling even & odd numbers with odious and evil numbers]
a(n) = A258746(A180201(n)) = A180201(A117120(n)), n > 0. - Yosu Yurramendi, Apr 10 2017

A268830 Square array A(r,c): A(0,c) = c, A(r,0) = 0, A(r>=1,c>=1) = 1+A(r-1,A268718(c)-1) = 1 + A(r-1, A003188(A006068(c)-1)), read by descending antidiagonals.

Original entry on oeis.org

0, 1, 0, 2, 1, 0, 3, 4, 1, 0, 4, 2, 3, 1, 0, 5, 6, 2, 3, 1, 0, 6, 8, 9, 2, 3, 1, 0, 7, 3, 8, 9, 2, 3, 1, 0, 8, 7, 5, 5, 6, 2, 3, 1, 0, 9, 10, 4, 4, 7, 8, 2, 3, 1, 0, 10, 12, 13, 6, 4, 6, 7, 2, 3, 1, 0, 11, 15, 12, 13, 5, 4, 6, 7, 2, 3, 1, 0, 12, 11, 17, 17, 18, 5, 4, 6, 7, 2, 3, 1, 0, 13, 5, 16, 16, 19, 20, 5, 4, 6, 7, 2, 3, 1, 0, 14, 13, 7, 18, 16, 18, 19, 5, 4, 6, 7, 2, 3, 1, 0
Offset: 0

Views

Author

Antti Karttunen, Feb 14 2016

Keywords

Examples

			The top left [0 .. 16] x [0 .. 19] section of the array:
0, 1, 2, 3, 4, 5, 6, 7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
0, 1, 4, 2, 6, 8, 3, 7, 10, 12, 15, 11,  5, 13, 16, 14, 18, 20, 23, 19
0, 1, 3, 2, 9, 8, 5, 4, 13, 12, 17, 16,  7,  6, 15, 14, 21, 20, 25, 24
0, 1, 3, 2, 9, 5, 4, 6, 13, 17, 16, 18, 10,  8, 15,  7, 21, 25, 24, 26
0, 1, 3, 2, 6, 7, 4, 5, 18, 19, 16, 17, 10, 11,  8,  9, 26, 27, 24, 25
0, 1, 3, 2, 8, 6, 4, 5, 20, 18,  9, 17,  7, 11, 10, 12, 28, 26, 33, 25
0, 1, 3, 2, 7, 6, 4, 5, 19, 18, 11, 10,  9,  8, 13, 12, 27, 26, 35, 34
0, 1, 3, 2, 7, 6, 4, 5, 19, 11, 14, 12,  8, 10, 13,  9, 27, 35, 38, 36
0, 1, 3, 2, 7, 6, 4, 5, 12, 13, 14, 15,  8,  9, 10, 11, 36, 37, 38, 39
0, 1, 3, 2, 7, 6, 4, 5, 14, 16, 11, 15,  8,  9, 12, 10, 38, 40, 35, 39
0, 1, 3, 2, 7, 6, 4, 5, 17, 16, 13, 12,  8,  9, 11, 10, 41, 40, 37, 36
0, 1, 3, 2, 7, 6, 4, 5, 17, 13, 12, 14,  8,  9, 11, 10, 41, 37, 36, 38
0, 1, 3, 2, 7, 6, 4, 5, 14, 15, 12, 13,  8,  9, 11, 10, 38, 39, 36, 37
0, 1, 3, 2, 7, 6, 4, 5, 16, 14, 12, 13,  8,  9, 11, 10, 40, 38, 21, 37
0, 1, 3, 2, 7, 6, 4, 5, 15, 14, 12, 13,  8,  9, 11, 10, 39, 38, 23, 22
0, 1, 3, 2, 7, 6, 4, 5, 15, 14, 12, 13,  8,  9, 11, 10, 39, 23, 26, 24
0, 1, 3, 2, 7, 6, 4, 5, 15, 14, 12, 13,  8,  9, 11, 10, 24, 25, 26, 27
		

Crossrefs

Inverses of these permutations can be found in table A268820.
Row 0: A001477, Row 1: A268718, Row 2: A268822, Row 3: A268824, Row 4: A268826, Row 5: A268828, Row 6: A268832, Row 7: A268934.
Rows converge towards A006068.

Programs

  • Python
    def a003188(n): return n^(n>>1)
    def a006068(n):
        s=1
        while True:
            ns=n>>s
            if ns==0: break
            n=n^ns
            s<<=1
        return n
    def a278618(n): return 0 if n==0 else 1 + a003188(a006068(n) - 1)
    def A(r, c): return c if r==0 else 0 if c==0 else 1 + A(r - 1, a278618(c) - 1)
    for r in range(21): print([A(c, r - c) for c in range(r + 1)]) # Indranil Ghosh, Jun 07 2017
  • Scheme
    (define (A268830 n) (A268830bi (A002262 n) (A025581 n))) ;; o=0: Square array of shifted powers of A268718.
    (define (A268830bi row col) (cond ((zero? row) col) ((zero? col) 0) (else (+ 1 (A268830bi (- row 1) (- (A268718 col) 1))))))
    (define (A268830bi row col) (cond ((zero? row) col) ((zero? col) 0) (else (+ 1 (A268830bi (- row 1) (A003188 (+ -1 (A006068 col))))))))
    
Showing 1-10 of 214 results. Next