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.

A338237 a(n) is the number of nodes with depth of n in a binary tree defined as: root = 1 and a child (C) of a node (N) is such that C - primepi(C) = N, or A062298(C) = N. For a node with two children, the smaller child is assigned as the left child and the bigger one as the right child. Otherwise, the child is assigned as the left child.

Original entry on oeis.org

1, 2, 4, 6, 8, 11, 15, 18, 24, 30, 36, 46, 54, 66, 78, 94, 110, 130, 154, 179, 205, 240, 278, 317, 365, 418, 474, 539, 612, 692, 783, 885, 993, 1116, 1254, 1399, 1570, 1752, 1950, 2166, 2408, 2690, 2976, 3287, 3644, 4023, 4449, 4892, 5391, 5946, 6523, 7169
Offset: 0

Views

Author

Ya-Ping Lu, Oct 17 2020

Keywords

Comments

The binary tree, read from left to right in the order of increasing depth n, is the positive integer sequence A000027. The first 65 numbers in the binary tree are shown in the figure below.
1
/ \
2 3
/ \ / \
4 5 6 7
/ / / \ / \
8 9 10 11 12 13
/ / / \ / \ / /
14 15 16 17 18 19 20 21
/ \ / / / / / \ / \ /
22 23 24 25 26 27 28 29 30 31 32
/ / / / \ / / / \ / \ / / / \
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
/ / / / / \ / / / / / \ / \ / / / /
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
Every node has either one child or two children and, thus, the binary tree has no leaves. All left children except 2 are composites and all odd primes are right children.
a(n) for n >= 1 in this sequence is the number of terms in A090532 having the value of n.
The left side of the binary tree is A025003 with a(1) = 1. A025003 is the smallest number that takes n steps to reach 1 when map A062298 is applied to an integer.
Starting from the root, there is only one path in which all nodes have two children. The path is 1 -> 3 -> 6 -> 11 -> 19 -> 29 - > 43 -> 60 -> 83, which contains 9 nodes.

Crossrefs

Programs

  • Mathematica
    c = q = 0; w = {}; Do[Set[a[i], If[PrimeQ[i], c++, a[i - c]]]; q++; If[a[i] == 0, AppendTo[w, q]; q = 0], {i, 2, 10^5}]; Most[w]  (* Michael De Vlieger, Nov 04 2021 *)
  • Python
    from sympy import primepi
    def depth(k):
        d = 0
        while k > 1:
            k -= primepi(k)
            d += 1
        return d
    m = 1
    for n in range (0, 101):
        a = 0
        while depth(m + a) == n:
            a += 1
        print(a)
        m += a

A025003 a(1) = 2; a(n+1) = a(n)-th nonprime, where nonprimes begin at 1.

Original entry on oeis.org

2, 4, 8, 14, 22, 33, 48, 66, 90, 120, 156, 202, 256, 322, 400, 494, 604, 734, 888, 1067, 1272, 1512, 1790, 2107, 2472, 2890, 3364, 3903, 4515, 5207, 5990, 6875, 7868, 8984, 10238, 11637, 13207, 14959, 16909, 19075, 21483, 24173, 27149, 30436, 34080, 38103
Offset: 1

Views

Author

Keywords

Comments

Index of first occurrence of n in A090532.
Let b(n) (n >= 0) be the smallest integer k >= 1 that takes n steps to reach 1 iterating the map f: k -> k - pi(k). The sequence {b(n), n >= 0} begins 1, 2, 4, 8, 14, 22, 33, 48, 66, 90, 120, 156, ... and agrees with the present sequence except for b(0). - Ya-Ping Lu, Sep 07 2020

Examples

			From _Ya-Ping Lu_, Sep 07 2020: (Start)
a(1) = 2 because f(2) = 2 - pi(2) = 1 and m(2) = 1;
For the integer 3, since f(3) = 1. m(3) = 1, which is not bigger than m(1) or m(2). So, 3 is not a term in the sequence;
a(2) = 4 because f^2(4) = f(2) = 1 and m(4) = 2;
a(3) = 8 because f^3(8) = f^2(4) = 1 and m(8) = 3. (End)
		

Crossrefs

Programs

  • Maple
    N:= 50: # to get a(0)..a(N)
    V:= Array(0..N):
    V[0]:= 1: V[1]:= 2:
    m:= 2: p:= 3: g:= 1: n:= 1:
    do
      if g+p-m-1 >= V[n] then
        m:= V[n]+m-g;
        n:= n+1;
        V[n]:= m;
        if n = N then break fi;
        g:= V[n-1];
      else
        g:= g+p-m;
        m:= p+1;
        p:= nextprime(m);
      fi;
    od;
    convert(V, list); # Robert Israel, Sep 08 2020
  • Python
    from sympy import prime, primepi
    n_last = 0
    pi_last = 0
    ct_max = -1
    for n in range(1, 100001):
        ct = 0
        pi = pi_last + primepi(n) - primepi(n_last)
        n_c = n
        pi_c = pi
        while n_c > 1:
            nc -= pi_c
            ct += 1
            pi_c -= primepi(n_c + pi_c) - primepi(n_c)
        if ct > ct_max:
            print(n)
            ct_max = ct
        n_last = n
        pi_last = pi # Ya-Ping Lu, Sep 07 2020

Formula

a(n) = min(k: f^n(k) = 1), where f = A062298 and n-fold iteration of f is denoted by f^n. - Ya-Ping Lu, Sep 07 2020
Showing 1-2 of 2 results.