OFFSET
1,1
COMMENTS
This is the lexicographically earliest sequence of distinct positive terms with this property. The prime digits are 2, 3, 5 and 7.
The sequence is first extended with the smallest odd term not leading to a contradiction; if no such term exists, the sequence is extended with the smallest even term not yet present.
EXAMPLE
Not a(1) = 1 as this 1, being odd, should be the sum of the prime digits so far -- which is wrong (there are none);
not a(1) = 2 as a(1) = 3 is odd and possible here;
a(12) = 9 as 9 is odd and the sum of the prime digits 3 + 2 + 2 + 2;
a(13) = 22 as 22 is the smallest even term available;
a(17) = 19 as 19 = 3 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2;
a(18) = 21 as 21 is the sum of 19 + 2 (the first digit of 21 itself); etc.
PROG
(Python)
def pds(k): return sum(int(d) for d in str(k) if d in "2357")
def aupto(nn):
aset, alst, primesum, nexteven = set(), [], 0, 2
for n in range(1, nn):
k = 1
found = False
while not found:
while k in aset: k += 2
if k == primesum + pds(k): found = True; break
if k > primesum + 7 * len(str(k)): break
k += 2
if found: ak = k
else: ak = nexteven; nexteven += 2
aset.add(ak); alst.append(ak); primesum += pds(ak)
return alst
print(aupto(76)) # Michael S. Branicky, Dec 29 2020
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Eric Angelini and Carole Dubois, Dec 28 2020
STATUS
approved