The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
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

%I #98 Nov 13 2022 02:04:07

%S 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,

%T 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,

%U -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

%N 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.

%C Empirical observation: -A000194(n) <= a(n) <= A000194(n).

%H Bence BernĂ¡th, <a href="/A337835/b337835.txt">Table of n, a(n) for n = 1..10000</a>

%e For n = 4, a(4) = 2, which appeared only once in the sequence so a(5)=1-2=-1.

%t a = {0}; Do[AppendTo[a, Count[a, a[[-1]]] - a[[-1]]], {100}]; a (* _Amiram Eldar_, Nov 18 2020 *)

%t 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 *)

%o (MATLAB)

%o length=1000;

%o sequence(1)=0;

%o for n=2:1:length

%o sequence(n)=nnz(sequence==sequence(end))-sequence(n-1);

%o end

%o (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

%o (Python)

%o from itertools import islice

%o from collections import Counter

%o def agen(): # generator of terms

%o an, k = 0, Counter()

%o while True:

%o yield an

%o k[an] += 1

%o an = k[an] - an

%o print(list(islice(agen(), 86))) # _Michael S. Branicky_, Nov 12 2022

%Y Cf. A000194, A329985.

%K sign,easy

%O 1,4

%A _Bence BernĂ¡th_, Nov 17 2020

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 May 31 17:16 EDT 2024. Contains 373003 sequences. (Running on oeis4.)