OFFSET
0,3
EXAMPLE
a(25) = 2 + 5 = 7.
a(37) = 3 + 7 + 37 = 47.
a(3002) = 3 + 2 = 5.
a(1235) = 2 + 3 + 5 + 23 = 33.
Example including duplicate and overlapping prime substrings:
a(227111) = 2 + 2 + 7 + 11 + 11 + 71 + 227 + 271 + 2711 + 227111 = 230424.
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.
Example wherein substrings with a leading 0 are to be ignored:
a(1002) = 2 because the substrings 002 and 02 are to be ignored due to the presence of a leading 0.
PROG
(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
(Python)
from sympy import isprime
def a(n):
s = str(n)
ss = (s[i:j] for i in range(len(s)) for j in range(i+1, len(s)+1))
return sum(p for w in ss if w[0]!="0" and isprime(p:=int(w)))
print([a(n) for n in range(81)]) # Michael S. Branicky, Aug 30 2023
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Wade Reece Eberly, Aug 30 2023
EXTENSIONS
More terms from Andrew Howroyd, Aug 30 2023
STATUS
approved