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.
%I A329428 #19 Feb 27 2020 23:17:13 %S A329428 0,1,1,1,4,1,6,4,8,9,10,1,12,6,14,15,16,4,18,8,10,1,12,9,14,15,16,4, %T A329428 18,10,10,1,12,9,14,15,16,12,18,10,40,6,42,14,44,45,46,15,48,49,10,1, %U A329428 12,16,14,15,16,12,18,4,60,18,62,63,64,65,66,8,68,69,40 %N A329428 Starting from n: as long as the decimal representation starts with a prime number, replace the largest such prefix with the index of the corresponding prime number; a(n) corresponds to the final value. %C A329428 As long as we have a number whose decimal representation is the concatenation of a prime number, say the k-th prime number, and a minimal string possibly empty or with leading zeros, say v, we replace this number with the concatenation of k and v; eventually none of the prefixes will be a prime number. %H A329428 Rémy Sigrist, <a href="/A329428/b329428.txt">Table of n, a(n) for n = 0..10000</a> %H A329428 Rémy Sigrist, <a href="/A329428/a329428.png">Scatterplot of the ordinal transform of the first 1000000 terms</a> %F A329428 a(n) <= n with equality iff n belongs to A202259. %F A329428 a(prime(k)) = a(k) for any k > 0 where prime(k) denotes the k-th prime number. %F A329428 a(10*k + v) = 10*a(k) + v for any k > 0 and v in {0, 2, 4, 5, 6, 8}. %F A329428 a(A007097(k)) = 1 for any k >= 0. %e A329428 For n = 991: %e A329428 - let pi denote A000720, %e A329428 - 991 gives pi(991) = 167, %e A329428 - 167 gives pi(167) = 39, %e A329428 - 39 gives pi(3) followed by 9 = 29, %e A329428 - 29 gives pi(29) = 10, %e A329428 - neither 1 nor 10 is a prime number, so a(991) = 10. %t A329428 Array[Which[# == 0, 0, # == 1, 1, True, FixedPoint[If[! IntegerQ@ #1, FromDigits[#2], FromDigits[Join @@ {IntegerDigits@ PrimePi@ #1, Drop[#2, IntegerLength@ #1]}]] & @@ {SelectFirst[Table[FromDigits[#[[1 ;; i]]], {i, Length@ #, 1, -1}], PrimeQ], #} &@ IntegerDigits[#] &, #]] &, 71, 0] (* _Michael De Vlieger_, Dec 01 2019 *) %t A329428 f[n_]:=Block[{p,r,d = IntegerDigits@ n,v=n}, Do[{p,r}= FromDigits/@ TakeDrop[d,k]; If[PrimeQ@ p, v=PrimePi[p] 10^(Length[d]-k)+r; Break[]],{k, Length@d, 1, -1}]; v]; a[n_]:= FixedPoint[f, n]; Array[a,71,0] (* _Giovanni Resta_, Dec 02 2019 *) %o A329428 (PARI) t(n) = if (n==0, 0, isprime(n), primepi(n), 10*t(n\10)+(n%10)) %o A329428 a(n) = while (n!=n=t(n),); n %Y A329428 See A327539 for similar sequences. %Y A329428 Cf. A007097, A202259. %K A329428 nonn,base %O A329428 0,5 %A A329428 _Rémy Sigrist_, Nov 30 2019