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-5 of 5 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

A316905 a(n) is the index of the first occurrence of n in A316774.

Original entry on oeis.org

0, 1, 2, 5, 4, 8, 11, 22, 14, 32, 28, 42, 48, 45, 68, 71, 77, 89, 108, 115, 92, 140, 95, 149, 216, 268, 194, 260, 310, 254, 263, 340, 362, 257, 295, 277, 298, 476, 346, 431, 365, 560, 539, 424, 486, 462, 576, 479, 579, 692, 657, 707, 754, 794, 757, 797, 928
Offset: 0

Views

Author

Alois P. Heinz, Jul 18 2018

Keywords

Examples

			a(4) = 4 because A316774(j) = 4 for j in {4,7,12,13,36,49,55} with minimal element 4.
		

Crossrefs

Cf. A316774, A316973, A316984, A330440 (a sorted version of this), A330447, A330448.

Programs

  • Maple
    b:= proc() 0 end:
    g:= proc(n) option remember; local t;
          t:= `if`(n<2, n, b(g(n-1))+b(g(n-2)));
          b(t):= b(t)+1; t
        end:
    a:= proc() local t, a; t, a:= -1, proc() -1 end;
          proc(n) local h;
            while a(n) = -1 do
              t:= t+1; h:= g(t);
              if a(h) = -1 then a(h):= t fi
            od; a(n)
          end
        end():
    seq(a(n), n=0..100);
  • Mathematica
    b[_] = 0;
    g[n_] := g[n] = Module[{t}, t = If[n < 2, n, b[g[n - 1]] + b[g[n - 2]]];       b[t] = b[t] + 1; t];
    a[n_] := Module[{t = -1, a}, a[_] = -1; Module[{h}, While[a[n] == -1, t = t + 1; h = g[t]; If[a[h] == -1, a[h] = t]]; a[n]]];
    Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Aug 28 2023, after Alois P. Heinz *)

Formula

a(n) = min { j >= 0 : A316774(j) = n }.

A316973 a(n) is the number of occurrences of n in A316774.

Original entry on oeis.org

1, 1, 3, 4, 7, 7, 15, 12, 18, 16, 25, 23, 14, 22, 26, 33, 23, 38, 32, 35, 45, 49, 41, 44, 58, 49, 59, 39, 49, 69, 54, 57, 57, 75, 79, 62, 75, 76, 74, 81, 75, 78, 74, 90, 86, 86, 88, 78, 78, 105, 106, 109, 129, 91, 92, 111, 108, 101, 126, 130, 116, 129, 133, 140
Offset: 0

Views

Author

Alois P. Heinz, Jul 17 2018

Keywords

Comments

These values may be only conjectural, in which case the b-file should be changed to an a-file and marked as conjectured. - N. J. A. Sloane, Dec 14 2019

Examples

			a(4) = 7 because A316774(j) = 4 for j in s = {4,7,12,13,36,49,55} and |s| = 7.
		

Crossrefs

Formula

a(n) = |{ j : A316774(j) = n }|.

A330330 Record high points in A316774.

Original entry on oeis.org

0, 1, 2, 4, 5, 6, 8, 10, 11, 13, 14, 15, 16, 17, 20, 22, 23, 26, 29, 33, 35, 36, 38, 40, 43, 45, 47, 48, 50, 51, 52, 54, 55, 56, 58, 60, 62, 65, 66, 71, 72, 73, 74, 75, 77, 78, 80, 81, 83, 84, 91, 98, 102, 111, 112, 118, 120, 124, 131, 136, 139, 144, 145, 147, 149, 152, 156, 159, 160, 163
Offset: 1

Views

Author

N. J. A. Sloane, Dec 14 2019

Keywords

Crossrefs

A330331 Positions of records in A316774.

Original entry on oeis.org

0, 1, 2, 4, 8, 11, 14, 28, 42, 45, 68, 71, 77, 89, 92, 95, 149, 194, 254, 257, 277, 298, 346, 365, 424, 462, 479, 579, 657, 707, 754, 757, 797, 928, 1107, 1110, 1147, 1150, 1295, 1298, 1453, 1456, 1462, 1590, 1593, 1673, 1676, 1819, 1822, 1982, 2095, 2395, 2593, 2665, 2874, 3355, 3724, 3873, 4131, 4359, 4510
Offset: 1

Views

Author

N. J. A. Sloane, Dec 14 2019

Keywords

Crossrefs

Showing 1-5 of 5 results.