login
Every nonprime term k of the sequence is the cumulative sum of the nonprime digits used so far (the digits of k are included in the sum).
5

%I #15 Nov 23 2020 07:56:45

%S 0,1,2,3,5,7,11,13,17,19,23,29,31,25,37,41,30,34,43,42,47,53,59,55,61,

%T 67,71,73,79,83,89,97,101,103,107,109,113,127,130,131,133,137,135,139,

%U 149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277

%N Every nonprime term k of the sequence is the cumulative sum of the nonprime digits used so far (the digits of k are included in the sum).

%C This is the lexicographically earliest sequence of distinct nonnegative terms with this property. The nonprime digits are 0, 1, 4, 6, 8 and 9.

%H Carole Dubois, <a href="/A338925/b338925.txt">Table of n, a(n) for n = 1..5000</a>

%e a(1) = 0 as 0 (a nonprime term) is the sum of all nonprime digits used so far;

%e a(2) = 1 as 1 (a nonprime term) is the sum of all nonprime digits used so far (0 + 1);

%e a(3) = 2 as 2 (a prime term) is the smallest term not yet present in the sequence that doesn't lead to a contradiction;

%e ...

%e a(14) = 25 (a nonprime term) as 25 is the sum of all nonprime digits used so far (0 + 1 + 1 + 1 + 1 + 1 + 1 + 9 + 9 + 1);

%e a(15) = 37 (a prime term) as 37 is the smallest term not yet present in the sequence that doesn't lead to a contradiction; etc.

%o (PARI) v=[0];w=[0];n=1;p=1;while(n<75,for(q=vecsum(w),nextprime(p+1),if(!isprime(q),m=[];for(k=1,#digits(q),if(!isprime(digits(q)[k]),m=concat(m,digits(q)[k])));c=0;if(vecsum(w)+vecsum(m)==q&&!vecsearch(vecsort(v),q),v=concat(v,q);w=concat(w,m);c++;break)));if(c==0,p=nextprime(p+1);for(j=1,#digits(p),if(!isprime(digits(p)[j]),w=concat(w,digits(p)[j])));v=concat(v,p));n++);v \\ _Derek Orr_, Nov 16 2020

%Y Cf. A338922, A338923 and A338924 (variants on the same idea).

%K base,nonn

%O 1,3

%A _Eric Angelini_ and _Carole Dubois_, Nov 15 2020