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.

A337014 a(1) = 0 and for n > 1, a(n+1) = (k(n) - a(n))*(-1)^(n+1) where k(n) is the number of terms equal to a(n) among the first n terms.

This page as a plain text file.
%I A337014 #31 Nov 13 2022 02:04:10
%S A337014 0,1,0,2,1,1,-2,3,2,0,-3,4,3,-1,-2,4,2,1,-3,5,4,-1,-3,6,5,-3,-7,8,7,
%T A337014 -6,-7,9,8,-6,-8,9,7,-5,-6,9,6,-4,-5,7,4,0,-4,6,3,0,-5,8,5,-2,-5,9,5,
%U A337014 -1,-4,7,3,1,-4,8,4,1,-5,10,9,-4,-9,10,8,-3,-8,10,7,-2,-6,10,6,-2,-7
%N A337014 a(1) = 0 and for n > 1, a(n+1) = (k(n) - a(n))*(-1)^(n+1) where k(n) is the number of terms equal to a(n) among the first n terms.
%C A337014 The graph of the sequence shows interesting, "Christmas tree"-like shapes.
%H A337014 Bence Bernáth, <a href="/A337014/b337014.txt">Table of n, a(n) for n = 1..10000</a>
%e A337014 For n = 4, a(4) = 2, which appeared only once before, so a(5)=(1-2)*(-1)^5 = 1.
%t A337014 a = {0}; Do[AppendTo[a, (-1)^k*(Count[a, a[[-1]]] - a[[-1]])], {k, 0, 81}]; a (* _Amiram Eldar_, Nov 21 2020 *)
%o A337014 (MATLAB)
%o A337014 length=10000;
%o A337014 sequence(1)=0;
%o A337014 for n=2:1:length
%o A337014      sequence(n)=((nnz(sequence==sequence(end)))-(sequence(n-1)))*(-1)^n;
%o A337014 end
%o A337014 (PARI) { for (n=1, #a=vector(83), print1(a[n]=if (n==1, 0, k=sum(k=1, n-1, a[k]==a[n-1]); (k-a[n-1])*(-1)^n) ", ")) } \\ _Rémy Sigrist_, Nov 22 2020
%o A337014 (Python)
%o A337014 from itertools import islice
%o A337014 from collections import Counter
%o A337014 def agen(): # generator of terms
%o A337014     an, k, sign = 0, Counter(), -1
%o A337014     while True:
%o A337014         yield an
%o A337014         k[an] += 1
%o A337014         sign *= -1
%o A337014         an = (k[an] - an)*sign
%o A337014 print(list(islice(agen(), 83))) # _Michael S. Branicky_, Nov 12 2022
%Y A337014 Cf. A337835, A329985.
%K A337014 sign,look
%O A337014 1,4
%A A337014 _Bence Bernáth_, Nov 21 2020