(Translated by https://www.hiragana.jp/)
A003324 - OEIS
login
A003324
A nonrepetitive sequence.
(Formerly M0443)
11
1, 2, 3, 4, 1, 4, 3, 2, 1, 2, 3, 2, 1, 4, 3, 4, 1, 2, 3, 4, 1, 4, 3, 4, 1, 2, 3, 2, 1, 4, 3, 2, 1, 2, 3, 4, 1, 4, 3, 2, 1, 2, 3, 2, 1, 4, 3, 2, 1, 2, 3, 4, 1, 4, 3, 4, 1, 2, 3, 2, 1, 4, 3, 4, 1, 2, 3, 4, 1
OFFSET
1,2
COMMENTS
Let b(0) be the sequence 1,2,3,4. Proceeding by induction, let b(n) be a sequence of length 2^(n+2). Quarter b(n) into four blocks, A,B,C,D each of length 2^n, so that b(n) = ABCD. Then b(n+1) = ABCDADCB. [After Dean paper.] - Sean A. Irvine, Apr 20 2015
REFERENCES
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
LINKS
Richard A. Dean, A sequence without repeats on x, x^{-1}, y, y^{-1}, Amer. Math. Monthly 72, 1965. pp. 383-385. MR 31 #350.
Françoise Dejean, Sur un Théorème de Thue, J. Combinatorial Theory, vol. 13 A, iss. 1 (1972) 90-99.
N. J. A. Sloane, P. Flor, L. F. Meyers, G. A. Hedlund. M. Gardner, Collection of documents and notes related to A1285, A3270, A3324
FORMULA
a(n) = n mod 4 for odd n; for even n, write n = (2*k+1) * 2^e, then a(n) = 2 if k+e is odd, 4 if k+e is even. - Jianing Song, Apr 15 2021
Conjecture: a(2*n) = (A292077(n)+1)*2. Confirmed for first 1000 terms. - John Keith, Apr 18 2021 [This conjecture is correct. Write n = (2*k+1) * 2^e. If k+e is even, then we have A292077(n) = 0 and a(2n) = 2; if k+e is odd, then we have A292077(n) = 1 and a(2n) = 4. - Jianing Song, Nov 27 2021]
MATHEMATICA
b[0] = Range[4];
b[n_] := b[n] = Module[{aa, bb, cc, dd}, {aa, bb, cc, dd} = Partition[b[n - 1], 2^(n-1)]; Join[aa, bb, cc, dd, aa, dd, cc, bb] // Flatten];
b[5] (* Jean-François Alcover, Sep 27 2017 *)
a[n_] := If[OddQ[n], Mod[n, 4], Module[{e = IntegerExponent[n, 2], k}, k = (n/2^e - 1)/2; If[OddQ[k + e], 2, 4]]];
Array[a, 100] (* Jean-François Alcover, Apr 19 2021, after Jianing Song *)
PROG
(PARI) a(n) = if(n%2, n%4, my(e=valuation(n, 2), k=bittest(n, e+1)); if((k+e)%2, 2, 4)) \\ Jianing Song, Apr 15 2021
CROSSREFS
Positions of 1's, 2's, 3's and 4's: A016813, A343500, A004767, A343501.
Cf. A292077.
Sequence in context: A343251 A327464 A318308 * A110630 A343321 A238883
KEYWORD
nonn,nice,easy
STATUS
approved