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 10 results.

A163333 Self-inverse permutation of integers: A163327-conjugate of A163332.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Comments

The integers [0,(9^k)-1] are confined to range [0,(9^k)-1].

Crossrefs

a(n) = A163327(A163332(A163327(n))). A163334 & A163336 give two variants of the Peano curve in an N x N grid. Cf. also A163355.

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

A163336 Peano curve in an n X n grid, starting downwards from the top left corner, listed antidiagonally 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, 5, 1, 6, 4, 2, 47, 7, 3, 15, 48, 46, 8, 14, 16, 53, 49, 45, 9, 13, 17, 54, 52, 50, 44, 10, 12, 18, 59, 55, 51, 39, 43, 11, 23, 19, 60, 58, 56, 38, 40, 42, 24, 22, 20, 425, 61, 57, 69, 37, 41, 29, 25, 21, 141, 426, 424, 62, 68, 70, 36, 30, 28, 26, 140, 142, 431, 427
Offset: 0

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Examples

			The top left 9 X 9 corner of the array shows how this surjective self-avoiding walk begins (connect the terms in numerical order, 0-1-2-3-...):
   0  5  6 47 48 53 54 59 60
   1  4  7 46 49 52 55 58 61
   2  3  8 45 50 51 56 57 62
  15 14  9 44 39 38 69 68 63
  16 13 10 43 40 37 70 67 64
  17 12 11 42 41 36 71 66 65
  18 23 24 29 30 35 72 77 78
  19 22 25 28 31 34 73 76 79
  20 21 26 27 32 33 74 75 80
		

Crossrefs

Transpose: A163334. Inverse: A163337. a(n) = A163332(A163330(n)) = A163327(A163333(A163328(n))) = A163334(A061579(n)). One-based version: A163340. Row sums: A163342. Row 0: A163481. Column 0: A163480. Central diagonal: A163343.
See A163357 and A163359 for the Hilbert curve.

Programs

  • Mathematica
    b[{n_, k_}, {m_}] := (A[n, k] = m - 1);
    MapIndexed[b, List @@ PeanoCurve[4][[1]]];
    Table[A[n - k, k], {n, 0, 12}, {k, n, 0, -1}] // Flatten (* Jean-François Alcover, Mar 07 2021 *)

Extensions

Name corrected by Kevin Ryde, Aug 28 2020

A163332 Self-inverse permutation of the integers for constructing the Peano curve in an N X N grid.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Comments

The integers [0,(3^k)-1] are confined to range [0,(3^k)-1].
From Kevin Ryde, Sep 04 2020: (Start)
To calculate a(n), write n in ternary digits n[k],..,n[0], where n[0] is the least significant digit. Then the ternary digits of a(n) are a[j] = k^{n[j+1]+n[j+3]+...}(n[j]) where Peano's complement operator k^{s}(d) = d if s even or 2-d if s odd.
A single complement is k(d) = 2-d and the "exponent" is repeats k(k(k(...))). Sum s = n[j+1] + n[j+3] + ... is every second digit above j, so digit j flips 0 <-> 2 when an odd number of odd digits (1's) among these. The complement does not change digit parity so a second transformation re-complements back to the original digits and so self-inverse a(a(n)) = n.
Peano's curve is formed by digits of a(n) put alternately to x and y coordinates, so a(n) maps between the Peano curve the ternary Z-order curve per the formulas in A163528, A163529.
(End)

Crossrefs

Coordinates using this transform: A163528, A163529.
A163334 & A163336 give two variants of the Peano curve in an N X N grid.
Cf. A163355 (Hilbert curve).

Programs

  • Mathematica
    a[n_] := FromDigits[With[{d = Reverse@IntegerDigits[n, 3]}, Reverse@Table[
      If[EvenQ@Total@d[[j+1 ;; ;; 2]], d[[j]], 2-d[[j]]], {j, Length@d}]], 3];
    Array[a, 100] (* Andrey Zabolotskiy, Apr 08 2021, after Kevin Ryde *)
  • PARI
    a(n) = my(v=digits(n,3)); for(start=2,3, my(s=0); forstep(i=start,#v,2, s+=v[i-1]; if(s%2,v[i]=2-v[i]))); fromdigits(v,3); \\ Kevin Ryde, Sep 04 2020

Formula

a(n) = A163327(A163333(A163327(n))).

Extensions

Name corrected by Kevin Ryde, Aug 27 2020

A163325 Pick digits at the even distance from the least significant end of the ternary expansion of n, then convert back to decimal.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Examples

			11 in ternary base (A007089) is written as '102' (1*9 + 0*3 + 2), from which we pick the "zeroth" and 2nd digits from the right, giving '12' = 1*3 + 2 = 5, thus a(11) = 5.
		

Crossrefs

A059905 is an analogous sequence for binary.

Programs

  • PARI
    a(n) = fromdigits(digits(n,9)%3,3); \\ Kevin Ryde, May 14 2020

Formula

a(0) = 0, a(n) = (n mod 3) + 3*a(floor(n/9)).
a(n) = Sum_{k>=0} {A030341(n,k)*b(k)} where b is the sequence (1,0,3,0,9,0,27,0,81,0,243,0... = A254006): powers of 3 alternating with zeros. - Philippe Deléham, Oct 22 2011
A037314(a(n)) + 3*A037314(A163326(n)) = n for all n.

Extensions

Edited by Charles R Greathouse IV, Nov 01 2009

A163328 Square array A, where entry A(y,x) has the ternary digits of x interleaved with the ternary digits of y, converted back to decimal. Listed by antidiagonals: 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, 3, 2, 4, 6, 9, 5, 7, 27, 10, 12, 8, 28, 30, 11, 13, 15, 29, 31, 33, 18, 14, 16, 36, 32, 34, 54, 19, 21, 17, 37, 39, 35, 55, 57, 20, 22, 24, 38, 40, 42, 56, 58, 60, 81, 23, 25, 45, 41, 43, 63, 59, 61, 243, 82, 84, 26, 46, 48, 44, 64, 66, 62, 244, 246, 83, 85, 87, 47, 49
Offset: 0

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Examples

			From _Kevin Ryde_, Oct 06 2020: (Start)
Array A(y,x) read by downwards antidiagonals, so 0, 1,3, 2,4,6, etc.
        x=0   1   2   3   4   5   6   7   8
      +--------------------------------------
  y=0 |   0,  1,  2,  9, 10, 11, 18, 19, 20,
    1 |   3,  4,  5, 12, 13, 14, 21, 22,
    2 |   6,  7,  8, 15, 16, 17, 24,
    3 |  27, 28, 29, 36, 37, 38,
    4 |  30, 31, 32, 39, 40,
    5 |  33, 34, 35, 42,
    6 |  54, 55, 56,
    7 |  57, 58,
    8 |  60,
(End)
		

Crossrefs

Inverse: A163329. Transpose: A163330. Cf. A037314 (row y=0), A208665 (column x=0)
Cf. A054238 is an analogous sequence for binary. Cf. A007089, A163327, A163332, A163334.

Programs

Formula

a(n) = A037314(A025581(n)) + 3*A037314(A002262(n))
a(n) = A163327(A163330(n)).

Extensions

Edited by Charles R Greathouse IV, Nov 01 2009

A163326 Pick digits at the odd distance from the least significant end of the ternary expansion of n, then convert back to decimal.

Original entry on oeis.org

0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 3, 3, 3, 4, 4, 4, 5, 5, 5, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 6, 6, 6, 7, 7, 7, 8, 8, 8, 6, 6, 6, 7, 7, 7, 8, 8, 8, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0
Offset: 0

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Examples

			42 in ternary base (A007089) is written as '1120' (1*27 + 1*9 + 2*3 + 0), from which we pick the first and 3rd digits from the right (zero-based!), giving '12' = 1*3 + 2 = 5, thus a(42) = 5.
		

Crossrefs

A059906 is an analogous sequence for binary. Note that A037314(A163325(n)) + 3*A037314(A163326(n)) = n for all n. Cf. A007089, A163327-A163329.

Programs

  • PARI
    a(n) = fromdigits(digits(n,9)\3,3); \\ Kevin Ryde, May 15 2020

Formula

a(n) = A163325(floor(n/3))
a(n) = Sum_{k>=0} A030341(n,k)*b(k) with (b) = (0,1,0,3,0,9,0,27,0,81,0,243,0,...): powers of 3 alternating with zeros. - Philippe Deléham, Oct 22 2011

Extensions

Edited by Charles R Greathouse IV, Nov 01 2009

A163329 Inverse permutation to A163328.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Crossrefs

Inverse: A163328. a(n) = A163331(A163327(n)). A054239 is an analogous sequence for binary. Cf. A007089.

Programs

Formula

a(n) = A001477bi(A163325(n),A163326(n)), where A001477bi(x,y) = (((x+y)^2)+x+(3y))/2.

A163330 Square array A, where entry A(y,x) has the ternary digits of y interleaved with the ternary digits of x, converted back to decimal. Listed by antidiagonals: A(0,0), A(0,1), A(1,0), A(0,2), A(1,1), A(2,0), ...

Original entry on oeis.org

0, 3, 1, 6, 4, 2, 27, 7, 5, 9, 30, 28, 8, 12, 10, 33, 31, 29, 15, 13, 11, 54, 34, 32, 36, 16, 14, 18, 57, 55, 35, 39, 37, 17, 21, 19, 60, 58, 56, 42, 40, 38, 24, 22, 20, 243, 61, 59, 63, 43, 41, 45, 25, 23, 81, 246, 244, 62, 66, 64, 44, 48, 46, 26, 84, 82, 249, 247, 245
Offset: 0

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Crossrefs

Inverse: A163331. a(n) = A163327(A163328(n)). Transpose: A163328. Cf. A007089, A163327, A163332, A163334.

Programs

Formula

a(n) = 3*A037314(A025581(n)) + A037314(A002262(n))

A163331 Inverse permutation to A163330.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Crossrefs

Inverse: A163330. a(n) = A163329(A163327(n)). Cf. A007089.

Programs

Formula

a(n) = A001477bi(A163326(n),A163325(n)), where A001477bi(x,y) = (((x+y)^2)+x+(3y))/2.
Showing 1-10 of 10 results.