login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A337835 a(1) = 0 and for n > 1, a(n+1) = k - a(n) where k is the number of terms equal to a(n) among the first n terms. 3
0, 1, 0, 2, -1, 2, 0, 3, -2, 3, -1, 3, 0, 4, -3, 4, -2, 4, -1, 4, 0, 5, -4, 5, -3, 5, -2, 5, -1, 5, 0, 6, -5, 6, -4, 6, -3, 6, -2, 6, -1, 6, 0, 7, -6, 7, -5, 7, -4, 7, -3, 7, -2, 7, -1, 7, 0, 8, -7, 8, -6, 8, -5, 8, -4, 8, -3, 8, -2, 8, -1, 8, 0, 9, -8, 9, -7, 9, -6, 9, -5, 9, -4, 9, -3, 9 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,4
COMMENTS
Empirical observation: -A000194(n) <= a(n) <= A000194(n).
LINKS
EXAMPLE
For n = 4, a(4) = 2, which appeared only once in the sequence so a(5)=1-2=-1.
MATHEMATICA
a = {0}; Do[AppendTo[a, Count[a, a[[-1]]] - a[[-1]]], {100}]; a (* Amiram Eldar, Nov 18 2020 *)
a[1] = 0; a[n_Integer?Positive] := a[n] = Count[Array[a, n - 1], a[n - 1]] - a[n - 1]; Array[a, 101] (* Jan Mangaldan, Nov 27 2020 *)
PROG
(MATLAB)
length=1000;
sequence(1)=0;
for n=2:1:length
sequence(n)=nnz(sequence==sequence(end))-sequence(n-1);
end
(PARI) lista(nn) = {my(va = vector(nn)); for (n=2, nn, va[n] = #select(x->(x==va[n-1]), vector(n-1, k, va[k])) - va[n-1]; ); va; } \\ Michel Marcus, Nov 18 2020
(Python)
from itertools import islice
from collections import Counter
def agen(): # generator of terms
an, k = 0, Counter()
while True:
yield an
k[an] += 1
an = k[an] - an
print(list(islice(agen(), 86))) # Michael S. Branicky, Nov 12 2022
CROSSREFS
Sequence in context: A258120 A147786 A275019 * A119387 A335905 A055941
KEYWORD
sign,easy
AUTHOR
Bence Bernáth, Nov 17 2020
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 18:05 EDT 2024. Contains 371798 sequences. (Running on oeis4.)