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

A057300 Binary counter with odd/even bit positions swapped; base-4 counter with 1's replaced by 2's and vice versa.

Original entry on oeis.org

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

Views

Author

Marc LeBrun, Aug 24 2000

Keywords

Comments

A self-inverse permutation of the integers.
a(n) = n if and only if n can be written as 3*Sum_{k>=0} d_i*4^k, where d_i is either 0 or 1. - Jon Perry, Oct 06 2012
From Veselin Jungic, Mar 03 2015: (Start)
In 1988 A. F. Sidorenko, see the Sidorenko reference, used this sequence as an example of a permutation of the set of positive integers with the property that if positive integers i, j, and k form a 3-term arithmetic progression then the corresponding terms a(i), a(j), and a(k) do not form an arithmetic progression.
In the terminology introduced in the Brown, Jungic, and Poelstra reference, the sequence does not contain "double 3-term arithmetic progressions".
It is not difficult to check that this sequence is with unbounded gaps, i.e., for any positive number m there is a natural number n such that a(n+1) - a(n) > m.
It is an open question if every sequence of integers with bounded gaps must contain a double 3-term arithmetic progression. This problem is equivalent to the well known additive square problem in infinite words: Is it true that any infinite word with a finite set of integers as its alphabet contains two consecutive blocks of the same length and the same sum? For more details about the additive square problem in infinite words see the following references: Ardal, et al.; Brown and Freedman; Freedman; Grytczuk; Halbeisen and Hungerbuhler, and Pirillo and Varricchio.
The sequence was attributed to Sidorenko in P. Hegarty's paper "Permutations avoiding arithmetic patterns". In his paper Hegarty characterized the countably infinite abelian groups for which there exists a bijection mapping arithmetic progressions to non-arithmetic progressions. This was further generalized by Jungic and Sahasrabudhe. (End)

Examples

			a(31) = a(4*7+3) = 4*a(7) + a(3) = 4*11 + 3 = 47.
		

Crossrefs

Sequences used in definitions of this sequence: A000695, A059905, A059906.
Sequences with similar definitions: A057301, A126006, A126007, A126008, A163241, A163327.
A003986, A003987, A004198, A053985, A054240 are used to express relationships between sequence terms.

Programs

  • C
    #include 
    uint32_t a(uint32_t n) { return ((n & 0x55555555) << 1) | ((n & 0xaaaaaaaa) >> 1); } /* Falk Hüffner, Jan 23 2022 */
  • Maple
    a:= proc(n) option remember; `if`(n=0, 0,
          a(iquo(n, 4, 'r'))*4+[0, 2, 1, 3][r+1])
        end:
    seq(a(n), n=0..69);  # Alois P. Heinz, Jan 25 2022
  • Mathematica
    Table[FromDigits[IntegerDigits[n,4]/.{1->2,2->1},4],{n,0,70}] (* Harvey P. Dale, Aug 24 2017 *)
  • PARI
    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); }; \\ Antti Karttunen, Apr 14 2018
    

Formula

Conjecture: a(2*n) = -2*a(n) + 5*n, a(2*n+1) = -2*a(n) + 5*n + 2. - Ralf Stephan, Oct 11 2003
a(4n+k) = 4a(n) + a(k), 0 <= k <= 3. - Jon Perry, Oct 06 2012
a(n) = A000695(A059906(n)) + 2*A000695(A059905(n)). - Antti Karttunen, Apr 14 2018
From Peter Munn, Dec 10 2019: (Start)
a(a(n)) = n.
a(A000695(m) + 2*A000695(n)) = 2*A000695(m) + A000695(n).
a(n OR k) = a(n) OR a(k), where OR is bitwise-or (A003986).
a(n XOR k) = a(n) XOR a(k), where XOR is bitwise exclusive-or (A003987).
a(n AND k) = a(n) AND a(k), where AND is bitwise-and (A004198).
a(A054240(n,k)) = A054240(a(n), a(k)). (End)
a(n) = 5*n/4 - 3*A053985(2*n)/8. - Alan Michael Gómez Calderón, May 20 2025

A163327 Self-inverse permutation of integers: swap the odd- and even-positioned digits in the ternary expansion of n, then convert back to decimal.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Examples

			11 in ternary base (A007089) is written as '(000...)102' (... + 0*27 + 1*9 + 0*3 + 2), which results '1020' = 1*27 + 0*9 + 2*3 + 0 = 33, when the odd- and even-positioned digits are swapped, thus a(11) = 33.
		

Crossrefs

Programs

  • Python
    from sympy.ntheory import digits
    def a(n):
        d = digits(n, 3)[1:]
        return sum(3**(i+(1-2*(i&1)))*di for i, di in enumerate(d[::-1]))
    print([a(n) for n in range(72)]) # Michael S. Branicky, Aug 05 2022
  • Scheme
    (define (A163327 n) (+ (A037314 (A163326 n)) (* 3 (A037314 (A163325 n)))))
    

Formula

a(n) = A037314(A163326(n)) + 3*A037314(A163325(n))

Extensions

Edited by Charles R Greathouse IV, Nov 01 2009

A126007 Involution of nonnegative integers: Keep the least significant quaternary digit q0 of n fixed, but swap the positions of digits q1 <-> q2, q3 <-> q4, ..., etc. in the base-4 expansion of n (where n = ... + q4*256 + q3*64 + q2*16 + q1*4 + q0).

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jan 02 2007

Keywords

Crossrefs

Programs

  • C
    #include 
    uint32_t a(uint32_t n) { return ((n & 0xcccccccc) << 2) | ((n & 0x33333330) >> 2) | (n & 3); } /* Falk Hüffner, Jan 23 2022 */
    
  • PARI
    f(n) = my(d=Vecrev(digits(n, 4))); if (#d % 2, d = concat(d, 0)); fromdigits(Vecrev(vector(#d, i, d[i+(-1)^(i-1)])), 4); \\ A126006
    a(n) = (n % 4) + 4*f(n\4); \\ Michel Marcus, Jan 23 2022

Formula

a(n) = (n mod 4) + 4*A126006(floor(n/4)).
a(n) = A057300(A126008(n)) = A126008(A057300(n)).

A341288 Square array T(n, k), read by antidiagonals, n, k >= 0; T(n, k) = XOR_{u in B(n), v in B(k)} 2^(u XOR v) where XOR denotes the bitwise XOR operator and B(n) gives the exponents in expression for n as a sum of powers of 2.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Feb 08 2021

Keywords

Comments

For any x >= 0, the function n -> T(n, 2^x) is a self-inverse permutation of the nonnegative integers.
The set of nonnegative integers equipped with T forms a commutative monoid; its invertible elements are the odious numbers (A000069).
Hence A000069 equipped with T forms a group.

Examples

			Array T(n, k) begins:
  n\k|  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
  ---+---------------------------------------------------------------
    0|  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
    1|  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
    2|  0   2   1   3   8  10   9  11   4   6   5   7  12  14  13  15 -> A057300
    3|  0   3   3   0  12  15  15  12  12  15  15  12   0   3   3   0
    4|  0   4   8  12   1   5   9  13   2   6  10  14   3   7  11  15 -> A126006
    5|  0   5  10  15   5   0  15  10  10  15   0   5  15  10   5   0
    6|  0   6   9  15   9  15   0   6   6   0  15   9  15   9   6   0
    7|  0   7  11  12  13  10   6   1  14   9   5   2   3   4   8  15
    8|  0   8   4  12   2  10   6  14   1   9   5  13   3  11   7  15
    9|  0   9   6  15   6  15   0   9   9   0  15   6  15   6   9   0
   10|  0  10   5  15  10   0  15   5   5  15   0  10  15   5  10   0
   11|  0  11   7  12  14   5   9   2  13   6  10   1   3   8   4  15
   12|  0  12  12   0   3  15  15   3   3  15  15   3   0  12  12   0
   13|  0  13  14   3   7  10   9   4  11   6   5   8  12   1   2  15
   14|  0  14  13   3  11   5   6   8   7   9  10   4  12   2   1  15
   15|  0  15  15   0  15   0   0  15  15   0   0  15   0  15  15   0
                                                                     \
                                                                      v
                                                                    A010060
		

Crossrefs

Programs

  • PARI
    B(n) = { my (b=vector(hammingweight(n))); for (k=1, #b, n -= 2^(b[k] = valuation(n, 2))); b }
    T(n,k) = { my (nn=B(n), kk=B(k), v=0); for (i=1, #nn, for (j=1, #kk, v=bitxor(v, 2^bitxor(nn[i], kk[j])))); v }

Formula

T(n, k) = T(k, n) (T is commutative).
T(m, T(n, k)) = T(T(m, n), k) (T is associative).
T(n, 0) = 0 (0 is an absorbing element for T).
T(n, 1) = n (1 is the neutral element for T).
T(n, 2) = A057300(n).
T(n, 4) = A126006(n).
T(n, n) = A010060(n).
A010060(T(n, k)) = A010060(n) * A010060(k).

A341489 Third row of A341458.

Original entry on oeis.org

3, 5, 1, 7, 2, 8, 4, 6, 33, 39, 35, 37, 36, 38, 34, 40, 65, 71, 67, 69, 68, 70, 66, 72, 99, 101, 97, 103, 98, 104, 100, 102, 9, 15, 11, 13, 12, 14, 10, 16, 43, 45, 41, 47, 42, 48, 44, 46, 75, 77, 73, 79, 74, 80, 76, 78, 105, 111, 107, 109, 108, 110, 106, 112
Offset: 1

Views

Author

Rémy Sigrist, Feb 13 2021

Keywords

Comments

This sequence is a self-inverse permutation of the positive integers.
This sequence has similarities with A126006.

Examples

			a(4) = A341458(3, 4) = 7.
		

Crossrefs

Programs

  • PARI
    See Links section.

Formula

a(n) = A341458(3, n).
Showing 1-5 of 5 results.