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.
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
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)
Links
- Michael De Vlieger, Table of n, a(n) for n = 2..10238 (as an irregular triangle, rows 1 <= n <= 35 flattened).
- Michael De Vlieger, Log-log scatterplot of a(n), for n=1..2^16.
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
Comments