[go: up one dir, main page]

login
A338941
a(1)=1. For n >= 2, let S be the sum of all prime digits in a(1), a(2), ... a(n-1) and let C be the next nonprime number not already in the sequence. If S is a prime less than C and is not already a term of the sequence, a(n) = S. Otherwise, a(n) = C.
0
1, 4, 6, 8, 9, 10, 12, 2, 14, 15, 16, 18, 20, 11, 21, 13, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66, 68, 69, 70, 72, 74, 75, 76, 77, 78, 80, 81, 82, 84, 85, 86, 87, 88, 90
OFFSET
1,2
COMMENTS
Similar to A338924, however this sequence does not account for the prime digits of a(n) itself.
Each prime term is the sum of all prime digits of each previous term.
EXAMPLE
a(16) = 13 because the sum of the prime digits from the previous terms is 2+2+5+2+2 = 13 (a prime) and 13 is less than the next nonprime (22).
a(17) = 22 because the sum of the prime digits from the previous terms is 2+2+5+2+2+3 = 16 (a nonprime), so a(17) is the next nonprime in the sequence.
a(18) = 24 because the sum of the prime digits from the previous terms is 2+2+5+2+2+3+2+2 = 20 (a nonprime).
a(16) = 25 because the sum of the prime digits from the previous terms is 2+2+5+2+2+3+2+2+2 = 22 (a nonprime).
a(17) = 26 because the sum of the prime digits from the previous terms is 2+2+5+2+2+3+2+2+2+2+5 = 29 (a prime) but it is not less than the next nonprime (which is 26).
PROG
(PARI) a(n)=my(v=[1], S=0, k=1, C=4, m); while(k<n, while(isprime(C), C++); m=vecsum(select(isprime, digits(S))); if(isprime(S) && (S<C) && !vecsearch(vecsort(v), S), v=concat(v, S); S+=m, S+= vecsum(select(isprime, digits(C))); v=concat(v, C); C++); k++); v[#v]
CROSSREFS
Cf. A338924.
Sequence in context: A085558 A084984 A104499 * A137353 A336371 A167376
KEYWORD
nonn,base
AUTHOR
Eric Angelini and Derek Orr, Nov 17 2020
STATUS
approved