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.

Showing 1-2 of 2 results.

A316774 a(n) = n for n < 2, a(n) = freq(a(n-1),n) + freq(a(n-2),n) for n >= 2, where freq(i,j) is the number of times i appears in [a(0),a(1),...,a(j-1)].

Original entry on oeis.org

0, 1, 2, 2, 4, 3, 2, 4, 5, 3, 3, 6, 4, 4, 8, 5, 3, 6, 6, 6, 8, 6, 7, 6, 7, 8, 5, 6, 10, 8, 5, 8, 9, 6, 9, 10, 4, 7, 8, 9, 9, 8, 11, 8, 9, 13, 6, 10, 12, 4, 7, 10, 8, 13, 11, 4, 9, 13, 9, 10, 12, 7, 7, 12, 9, 11, 11, 8, 14, 11, 6, 15, 11, 7, 13, 11, 11, 16, 9, 10
Offset: 0

Views

Author

Peter Illig, Jul 12 2018

Keywords

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)

Examples

			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.
		

Crossrefs

Cf. A001462, A316973 (freq(n)), A316905 (when n appears), A316984 (when n last appears), A330439 (total number of times a(n) has appeared so far).
For records see A330330, A330331.
See A306246 and A329934 for similar sequences with different initial conditions.
A330332 considers the frequencies of the three previous terms.

Programs

  • 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 *)
  • 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

Extensions

Definition clarified by N. J. A. Sloane, Dec 13 2019

A364835 a(1) = 1; a(n+1) = (number of times a(n)+1 has appeared) - (number of times a(n) has appeared).

Original entry on oeis.org

1, -1, -1, -2, 1, -2, 0, 1, -3, 1, -4, 0, 2, -1, -1, -2, 1, -4, -1, -3, 1, -5, 1, -6, 0, 4, -1, -3, 0, 3, 0, 2, -1, -2, 3, -1, -3, 0, 1, -6, -1, -3, -1, -4, 2, -1, -5, 1, -6, -1, -6, -2, 7, -1, -7, 3, -2, 7, -2, 6, 1, -7, 2, -1, -8, 1, -7, 1, -8, 1, -9, 1, -10, 0, 7, -3, 1, -11, 0
Offset: 1

Views

Author

Rok Cestnik, Aug 28 2023

Keywords

Comments

Irregular until n=149695 at which point it follows a simple pattern (see formula).

Examples

			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.
		

Crossrefs

Programs

  • 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 *)
  • 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

Formula

For n >= 149695: a(n) = 49456 - n/3 if (n mod 3) = 0, otherwise a(n) = (n mod 3) - 1.
Showing 1-2 of 2 results.