OFFSET
0,3
COMMENTS
In other words, a(n) = (number of times a(n-1) has appeared) plus (number of times a(n-2) has appeared). - _N. J. A. Sloane_, Dec 13 2019
What is the asymptotic behavior of this sequence?
Does it contain every positive integer at least once?
Does it contain every positive integer at most finitely many times?
Additional comments from Peter Illig's "Puzzles" link below (Start):
Sometimes referred to as "The Devil's Sequence" (by me), due to the early presence of three consecutive 6's (and my inability to understand it). The next time a number occurs three times in a row isn't until a(355677).
If each n does appear only finitely many times, approximately how many times does it appear? (It seems to be close to 2n.)
What are the best possible upper/lower bounds on a(n)?
Let r(k) be the smallest n such that {0,1,2,...,k} is contained in {a(0),...,a(n)}. What is the asymptotic behavior of r(k)? (It seems to be close to k^2/2.)
(End)
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..65536
"Horseshoe_Crab" Reddit User, Properties of a Strange, Rather Meta Sequence. [In case this link breaks, the main point of the discussion is to propose the sequence and suggest other initial values. - _N. J. A. Sloane_, Dec 13 2019]
Peter Illig, Problems. [No date, probably 2018]
Samuel B. Reid, Density plot of one billion terms
Rémy Sigrist, Density plot of the first 10000000 terms
EXAMPLE
For n=4, a(n-1) = a(n-2) = 2, and 2 appears twice in the first 4 terms. So a(4) = 2 + 2 = 4.
MAPLE
b:= proc() 0 end:
a:= proc(n) option remember; local t;
t:= `if`(n<2, n, b(a(n-1))+b(a(n-2)));
b(t):= b(t)+1; t
end:
seq(a(n), n=0..200); # _Alois P. Heinz_, Jul 12 2018
MATHEMATICA
a = prev = {0, 1};
Do[
AppendTo[prev, Count[a, prev[[1]]] + Count[a, prev[[2]]]];
AppendTo[a, prev[[3]]];
prev = prev[[2 ;; ]] , {78}]
a (* _Peter Illig_, Jul 12 2018 *)
PROG
(Python)
from itertools import islice
from collections import Counter
def agen():
a = [0, 1]; c = Counter(a); yield from a
while True:
a = [a[-1], c[a[-1]] + c[a[-2]]]; c[a[-1]] += 1; yield a[-1]
print(list(islice(agen(), 80))) # _Michael S. Branicky_, Oct 13 2022
CROSSREFS
KEYWORD
nonn,look
AUTHOR
_Peter Illig_, Jul 12 2018
EXTENSIONS
Definition clarified by _N. J. A. Sloane_, Dec 13 2019
STATUS
approved