OFFSET
1,4
COMMENTS
Irregular until n=149695 at which point it follows a simple pattern (see formula).
LINKS
Rok Cestnik, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (0,0,2,0,0,-1).
FORMULA
For n >= 149695: a(n) = 49456 - n/3 if (n mod 3) = 0, otherwise a(n) = (n mod 3) - 1.
EXAMPLE
a(5) = 2 - 1 = 1 because a(4) + 1 = -1 has appeared twice before and a(4) = -2 has appeared once.
a(7) = 2 - 2 = 0 because a(6) + 1 = -1 and a(6) = -2 have both appeared twice before.
MATHEMATICA
nmax=78; a={1}; For[n=1, n<=nmax, n++, AppendTo[a, Count[a, Part[a, n]+1]-Count[a, Part[a, n]]]]; a (* Stefano Spezia, Aug 29 2023 *)
PROG
(Python)
a=[1]
for n in range(1000):
a.append(a.count(a[n]+1)-a.count(a[n]))
(Python)
from itertools import islice
from collections import Counter
def agen(): # generator of terms
an = 1; c = Counter([1])
while True: yield an; an = c[an+1] - c[an]; c[an] += 1
print(list(islice(agen(), 1001))) # Michael S. Branicky, Aug 29 2023
CROSSREFS
KEYWORD
AUTHOR
Rok Cestnik, Aug 28 2023
STATUS
approved