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-4 of 4 results.

A348907 If n is prime, a(n) = n, else a(n) = a(n-pi(n)), n >= 2; where pi is the prime counting function A000720.

Original entry on oeis.org

2, 3, 2, 5, 3, 7, 2, 5, 3, 11, 7, 13, 2, 5, 3, 17, 11, 19, 7, 13, 2, 23, 5, 3, 17, 11, 19, 29, 7, 31, 13, 2, 23, 5, 3, 37, 17, 11, 19, 41, 29, 43, 7, 31, 13, 47, 2, 23, 5, 3, 37, 53, 17, 11, 19, 41, 29, 59, 43, 61, 7, 31, 13, 47, 2, 67, 23, 5, 3, 71, 37, 73, 53, 17, 11
Offset: 2

Views

Author

David James Sycamore, Nov 03 2021

Keywords

Comments

A fractal sequence in which every term is prime. The proper subsequence a(k), for composite numbers k = 4,6,8,9... is identical to the original, and the records subsequence is A000040.
Regarding this sequence as an irregular triangle T(m,j) where the rows m terminate with 2 exhibits row length A338237(m). In such rows m, we have a permutation of the least A338237(m) primes. - Michael De Vlieger, Nov 04 2021

Examples

			2 is prime so a(2) = 2.
3 is prime so a(3) = 3.
4 is not prime so a(4) = a(4-pi(4)) = 2.
5 is prime so a(5) = 5.
6 is composite so a(6) = a(6-pi(6)) = 3.
From _Michael De Vlieger_, Nov 04 2021: (Start)
Table showing pi(a(n)) for the first rows m of this sequence seen as an irregular triangle T(m,j). "New" primes introduced for prime n are shown in parentheses:
m\j   1   2   3   4   5   6   7   8   9  10  11   A338237(m)
------------------------------------------------------------
1:   (1)                                                1
2:   (2)  1                                             2
3:   (3)  2  (4)  1                                     4
4:    3   2  (5)  4  (6)  1                             6
5:    3   2  (7)  5  (8)  4   6   1                     8
6:   (9)  3   2   7   5   8 (10)  4 (11)  6   1        11
... (End)
		

Crossrefs

Programs

  • Mathematica
    a[n_]:=If[PrimeQ@n,n,a[n-PrimePi@n]];Array[a,75,2] (* Giorgos Kalogeropoulos, Nov 03 2021 *)
  • PARI
    a(n) = if (isprime(n), n, a(n-primepi(n))); \\ Michel Marcus, Nov 03 2021
    
  • Python
    from sympy import isprime
    def aupton(nn):
        alst, primepi = [], 0
        for n in range(2, nn+1):
            if isprime(n): an, primepi = n, primepi + 1
            else: an = alst[n - primepi - 2]
            alst.append(an)
        return alst
    print(aupton(76)) # Michael S. Branicky, Nov 04 2021

Extensions

More terms from Michel Marcus, Nov 03 2021

A349191 a(n) = A000720(A348907(n+1)).

Original entry on oeis.org

1, 2, 1, 3, 2, 4, 1, 3, 2, 5, 4, 6, 1, 3, 2, 7, 5, 8, 4, 6, 1, 9, 3, 2, 7, 5, 8, 10, 4, 11, 6, 1, 9, 3, 2, 12, 7, 5, 8, 13, 10, 14, 4, 11, 6, 15, 1, 9, 3, 2, 12, 16, 7, 5, 8, 13, 10, 17, 14, 18, 4, 11, 6, 15, 1, 19, 9, 3, 2, 20, 12, 21, 16, 7, 5, 8, 13, 22, 10
Offset: 1

Views

Author

Michael De Vlieger, Nov 09 2021

Keywords

Comments

Regarding this sequence as an irregular triangle T(m,j) where the rows m terminate with 1 exhibits row length A338237(m). In such rows m, we have a permutation of the range of natural numbers 1..A338237(m).
Records are the natural numbers.

Examples

			Table showing a(n) for the first rows m of this sequence seen as an irregular triangle T(m,j). "New" numbers introduced for prime (n+1) are shown in parentheses:
  m\j   1   2   3   4   5   6   7   8   9  10  11   A338237(m)
  ------------------------------------------------------------
  1:   (1)                                                1
  2:   (2)  1                                             2
  3:   (3)  2  (4)  1                                     4
  4:    3   2  (5)  4  (6)  1                             6
  5:    3   2  (7)  5  (8)  4   6   1                     8
  6:   (9)  3   2   7   5   8 (10)  4 (11)  6   1        11
  ...
		

Crossrefs

Programs

  • Mathematica
    c = 0; 1 + Reap[Do[Set[a[i], If[PrimeQ[i], i; c++, a[i - c]] ]; Sow[a[i]], {i, 2, 2^24}] ][[-1, -1]]

A349192 Irregular triangle T(m,k) = inverse permutation of S(m,k) = A349191 read as an irregular triangle.

Original entry on oeis.org

1, 2, 1, 4, 2, 1, 3, 6, 2, 1, 4, 3, 5, 8, 2, 1, 6, 4, 7, 3, 5, 11, 3, 2, 8, 5, 10, 4, 6, 1, 7, 9, 15, 3, 2, 11, 6, 13, 5, 7, 1, 9, 12, 4, 8, 10, 14, 18, 3, 2, 14, 7, 16, 6, 8, 1, 10, 15, 4, 9, 12, 17, 5, 11, 13, 24, 4, 3, 19, 10, 21, 9, 11, 2, 14, 20, 6, 12, 16
Offset: 1

Views

Author

Michael De Vlieger, Nov 09 2021

Keywords

Comments

We find k at S(m,k) where S is A349191 read as an irregular triangle. Alternatively, we find prime(k) at U(m,k) where U is A348907 read as an irregular triangle.

Examples

			First rows of T(m,k):
  m\k   1   2   3   4   5   6   7   8   9  10  11
  -----------------------------------------------
  1:    1
  2:    2   1
  3:    4   2   1   3
  4:    6   2   1   4   3   5
  5:    8   2   1   6   4   7   3   5
  6:   11   3   2   8   5  10   4   6   1   7   9
  ...
		

Crossrefs

Programs

  • Mathematica
    c = 0; Flatten@ Map[Table[If[k == 1, Length[#] + 1, FirstPosition[#, k - 1][[1]]], {k, If[IntegerQ@ #, # + 1, 1] &@ Max[#]}] &, {{}}~Join~Most@ SplitBy[Reap[Do[Set[a[i], If[PrimeQ[i], i; c++, a[i - c]]]; Sow[a[i]], {i, 2, 100}]][[-1, -1]], # == 0 &][[2 ;; -1 ;; 2]]]

Formula

Row lengths are in A338237.

A338409 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 A338215(C) = N. For nodes with two children, the smaller child is assigned as the left child and the bigger one as the right child. A child of a one-child node is assigned as the left child.

Original entry on oeis.org

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

Views

Author

Ya-Ping Lu, Oct 24 2020

Keywords

Examples

			The binary tree, read from left to right in the order of increasing depth n, is the positive integer sequence A000027. The first 67 numbers 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   66 \_67
All left children except 2 are composite numbers and all prime numbers are right children.
		

Crossrefs

Programs

  • Python
    from sympy import primepi
    def depth(k):
        d = 0
        while k > 1:
            k -= primepi(k)
            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
Showing 1-4 of 4 results.