Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #25 Sep 29 2023 17:56:54
%S 0,0,2,3,0,5,0,7,0,0,0,11,2,16,0,5,0,24,0,19,2,2,4,28,2,7,2,9,2,31,3,
%T 34,5,6,3,8,3,47,3,3,0,41,2,46,0,5,0,54,0,0,5,5,7,61,5,10,5,12,5,64,0,
%U 61,2,3,0,5,0,74,0,0,7,78,9,83,7,12,7,14,7,86,0
%N Sum of all prime substrings of n in base 10, including n itself and duplicate or overlapping substrings but not substrings with a leading 0.
%e a(25) = 2 + 5 = 7.
%e a(37) = 3 + 7 + 37 = 47.
%e a(3002) = 3 + 2 = 5.
%e a(1235) = 2 + 3 + 5 + 23 = 33.
%e Example including duplicate and overlapping prime substrings:
%e a(227111) = 2 + 2 + 7 + 11 + 11 + 71 + 227 + 271 + 2711 + 227111 = 230424.
%e Note that in the above example, the substring 2 is incorporated into the sum twice because it appears twice in n. The same is true of the substring 11, whose two appearances overlap each other in the final three digits of n.
%e Example wherein substrings with a leading 0 are to be ignored:
%e a(1002) = 2 because the substrings 002 and 02 are to be ignored due to the presence of a leading 0.
%o (PARI) a(n)={my(v=digits(n)); sum(j=1, #v, sum(i=1, j, if(v[i], my(t=fromdigits(v[i..j])); t*isprime(t))))} \\ _Andrew Howroyd_, Aug 30 2023
%o (Python)
%o from sympy import isprime
%o def a(n):
%o s = str(n)
%o ss = (s[i:j] for i in range(len(s)) for j in range(i+1, len(s)+1))
%o return sum(p for w in ss if w[0]!="0" and isprime(p:=int(w)))
%o print([a(n) for n in range(81)]) # _Michael S. Branicky_, Aug 30 2023
%Y Cf. A035232, A225580.
%K nonn,base
%O 0,3
%A _Wade Reece Eberly_, Aug 30 2023
%E More terms from _Andrew Howroyd_, Aug 30 2023