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.
%I A003324 M0443 #55 Feb 26 2025 16:44:21 %S A003324 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, %T A003324 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 %N A003324 A nonrepetitive sequence. %C A003324 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 %D A003324 N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence). %H A003324 Sean A. Irvine, <a href="/A003324/b003324.txt">Table of n, a(n) for n = 1..10000</a> %H A003324 Richard A. Dean, <a href="http://www.jstor.org/stable/2313498">A sequence without repeats on x, x^{-1}, y, y^{-1}</a>, Amer. Math. Monthly 72, 1965. pp. 383-385. MR 31 #350. %H A003324 Françoise Dejean, <a href="http://dx.doi.org/10.1016/0097-3165(72)90011-8">Sur un Théorème de Thue</a>, J. Combinatorial Theory, vol. 13 A, iss. 1 (1972) 90-99. %H A003324 N. J. A. Sloane, P. Flor, L. F. Meyers, G. A. Hedlund. M. Gardner, <a href="/A001285/a001285.pdf">Collection of documents and notes related to A1285, A3270, A3324</a> %H A003324 Jianing Song, <a href="/A003324/a003324.pdf">Proof for my formula for A003324</a> %F A003324 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 %F A003324 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] %t A003324 b[0] = Range[4]; %t A003324 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]; %t A003324 b[5] (* _Jean-François Alcover_, Sep 27 2017 *) %t A003324 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]]]; %t A003324 Array[a, 100] (* _Jean-François Alcover_, Apr 19 2021, after _Jianing Song_ *) %o A003324 (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 %o A003324 (Python) %o A003324 def A003324(n): return n&3 if n&1 else 2<<(((n>>(m:=(~n&n-1).bit_length()))+1>>1)+m&1) # _Chai Wah Wu_, Feb 26 2025 %Y A003324 Positions of 1's, 2's, 3's and 4's: A016813, A343500, A004767, A343501. %Y A003324 Cf. A292077. %K A003324 nonn,nice,easy %O A003324 1,2 %A A003324 _N. J. A. Sloane_