login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A338938 a(1)=0. For n >= 2, let S be the sum of all nonprime digits in a(1), a(2), ... a(n-1) and let P be the next prime not already in the sequence. If S is a nonprime number less than P and not already in the sequence, a(n) = S. Otherwise, a(n) = P. 1

%I #16 Nov 22 2020 21:29:14

%S 0,2,3,5,7,11,13,17,4,8,16,19,23,29,31,37,41,43,47,53,56,59,61,67,71,

%T 73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,

%U 167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257

%N a(1)=0. For n >= 2, let S be the sum of all nonprime digits in a(1), a(2), ... a(n-1) and let P be the next prime not already in the sequence. If S is a nonprime number less than P and not already in the sequence, a(n) = S. Otherwise, a(n) = P.

%C Similar to A338925, however this sequence does not include the nonprime digits of a(n) itself.

%C Each nonprime term is the sum of all nonprime digits of each previous term.

%e a(9) = 4 since the sum of the nonprime digits of the previous terms is 1+1+1+1 = 4 and 4 is less than the next prime, 19.

%e a(10) = 8 since the sum of nonprime digits of the previous terms is 1+1+1+1+4 = 8 and 8 is less than the next prime, 19.

%e a(11) = 16 since the sum of the nonprime digits of the previous terms is 1+1+1+1+4+8 = 16 and 16 is less than the next prime, 19.

%e Now, the sum of the nonprime digits of the previous terms is 1+1+1+1+4+8+1+6 = 23 (a prime number). So a(12) is the next prime number in that hasn't appeared, meaning a(12) = 19.

%o (PARI) my(v=[0], w=[0], n=1, p=1, m, c); while(n<125, q=vecsum(w);m=[];p=nextprime(p);c=0; for(k=1,#digits(q),if(!isprime(digits(q)[k]),m=concat(m,digits(q)[k])));if(!isprime(q)&&(q<p)&& !vecsearch(vecsort(v),q),v=concat(v,q); w=concat(w,m); c++); if(c==0,for(j=1,#digits(p),if(!isprime(digits(p)[j]),w=concat(w,digits(p)[j]))); v=concat(v,p);p++);n++);v

%Y Cf. A338925.

%K nonn,base

%O 1,2

%A _Eric Angelini_ and _Derek Orr_, Nov 16 2020

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 03:08 EDT 2024. Contains 371918 sequences. (Running on oeis4.)