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.

A356273 a(n) is the position of the least prime in the ordered set of numbers obtained by inserting/placing any digit anywhere in the digits of n (except a zero before 1st digit), or 0 if there is no prime in that set.

This page as a plain text file.
%I A356273 #18 Aug 02 2022 09:20:05
%S A356273 2,5,1,5,8,7,1,11,1,2,1,10,1,14,7,10,1,10,1,0,4,7,4,7,8,11,1,11,4,10,
%T A356273 1,0,2,14,11,16,1,14,1,5,2,7,8,11,16,11,3,19,1,8,1,8,3,10,17,14,1,20,
%U A356273 3,7,4,0,1,11,14,13,1,17,2,8,2,16,1,14,13,14,2,22,1,17
%N A356273 a(n) is the position of the least prime in the ordered set of numbers obtained by inserting/placing any digit anywhere in the digits of n (except a zero before 1st digit), or 0 if there is no prime in that set.
%C A356273 It appears that a(n) = 0 for n in A124665.
%C A356273 891, a term of A124665 and with a(891) = 9, is the first counterexample. - _Michael S. Branicky_, Aug 01 2022
%H A356273 Michel Marcus, <a href="/A356273/b356273.txt">Table of n, a(n) for n = 1..10000</a>
%e A356273 For n=1, the resulting set is (10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 31, 41, 51, 61, 71, 81, 91) where the least prime 11 is at position 2, so a(1) = 2.
%e A356273 For n=2, the resulting set is (12, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 42, 52, 62, 72, 82, 92) where the least prime 23 is at position 5, so a(2) = 5.
%t A356273 Table[Function[w, If[IntegerQ[#], #, 0] &@ FirstPosition[Rest@ Union@ Flatten@ Table[FromDigits@ Insert[w, d, k], {k, Length[w] + 1, 1, -1}, {d, 0, 9}], _?PrimeQ][[1]]][IntegerDigits[n]], {n, 80}] (* _Michael De Vlieger_, Aug 01 2022 *)
%o A356273 (PARI) get(d, rd, n, k) = {if (n==0, return(fromdigits(concat(d, k)))); if (n==#d, return(fromdigits(concat(k, d)))); my(v = concat(Vec(d, #d-n), k)); v = concat(v, Vecrev(Vec(rd, n))); fromdigits(v);}
%o A356273 a(n) = {my(d=digits(n), rd = Vecrev(d), list = List(), p); for (n=0, #d, my(kstart = if (n==#d, 1, 0)); for (k=kstart, 9, listput(list, get(d, rd, n, k)););); my(svec = Set(Vec(list))); for (k=1, #svec, if (isprime(svec[k]), return(k)););}
%o A356273 (Python)
%o A356273 from sympy import isprime
%o A356273 def a(n):
%o A356273     s = str(n)
%o A356273     out = set(s[:i]+c+s[i:] for i in range(len(s)+1) for c in "0123456789")
%o A356273     out = sorted(int(k) for k in out if k[0] != "0")
%o A356273     ptest = (i for i, k in enumerate(sorted(out), 1) if isprime(int(k)))
%o A356273     return next(ptest, 0)
%o A356273 print([a(n) for n in range(1, 81)]) # _Michael S. Branicky_, Aug 01 2022
%Y A356273 Related to the process in A068166, A068167, A068169, A068170, A068171, A068172, A068173, and A068174.
%Y A356273 Cf. A124665.
%K A356273 nonn,base
%O A356273 1,1
%A A356273 _Michel Marcus_, Aug 01 2022