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.

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