The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
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!)
A284188 a(1)=2; thereafter a(n+1) = a(n)+i if a(n) is a prime and a(1),...,a(n) contains i primes, or a(n+1) = a(n)-i if a(n) is composite and a(1),...,a(n) contains i primes. 2

%I #18 Oct 20 2021 21:30:30

%S 2,3,5,8,5,9,5,10,5,11,18,11,19,28,19,29,40,29,41,54,41,55,41,56,41,

%T 57,41,58,41,59,78,59,79,100,79,101,124,101,125,101,126,101,127,154,

%U 127,155,127,156,127,157,188,157,189,157,190,157,191,226,191,227,264,227,265

%N a(1)=2; thereafter a(n+1) = a(n)+i if a(n) is a prime and a(1),...,a(n) contains i primes, or a(n+1) = a(n)-i if a(n) is composite and a(1),...,a(n) contains i primes.

%C Without repeated terms, the primes appear in order as A070865.

%C Variant of A284172; the difference is that in A284172, a(n+1) = a(n)-i if a(n) is composite and a(1),...,a(n) contains i composites (rather than i primes).

%C For n >= 3: When a(n) = prime p it is followed by an even number j at a(n+1); p repeats k-j times (where k is the smallest prime > j), appearing at a(n+2m) {m=1..k-j}. a(n+2m+1) = p+m until p+m = k (immediately following the final p); k now becomes "new p" immediately followed by a "new j", and the process repeats.

%H Alois P. Heinz, <a href="/A284188/b284188.txt">Table of n, a(n) for n = 1..100000</a>

%H Michael De Vlieger, <a href="/A284188/a284188.png">Log-log scatterplot of a(n)</a> for n=1..2^16.

%H Michael De Vlieger, <a href="/A284188/a284188_1.png">Log-log scatterplot of a(n)</a> for n=1..2^12, showing a(n) in red and A284172(n) in blue, accentuating the first 12 terms of A284172(n) by enlargement.

%e a(10) = 11; there are 7 primes in the sequence up to and including a(10) so a(11) = 11+7 = 18. 18 is composite so a(12) = 18-7 = 11. Now there are 8 primes in the sequence; and since 11 is prime, a(13) = 11+8 = 19 (the 9th prime in the sequence), so a(14) = 28.

%p c:= proc(n) option remember; `if`(n<1, 0,

%p `if`(isprime(a(n)), 1, 0)+c(n-1))

%p end:

%p a:= proc(n) option remember; `if`(n=1, 2, (m->

%p `if`(isprime(m), 1, -1)*c(n-1)+m)(a(n-1)))

%p end:

%p seq(a(n), n=1..100); # _Alois P. Heinz_, Apr 15 2017

%t Block[{c = 1, m = 2, n}, {2}~Join~Reap[Do[If[PrimeQ[m], Set[n, m + c]; c++, Set[n, m - c + 1]]; Sow[n]; m = n, 63]][[-1, -1]]] (* _Michael De Vlieger_, Oct 20 2021 *)

%o (PARI) lista(nn) = {print1(a=2, ", "); nbp = 1; for (n=2, nn, if (isprime(a), a += nbp, a -= nbp); print1(a, ", "); if (isprime(a), nbp++););} \\ _Michel Marcus_, Mar 24 2017

%Y Cf. A070865, A284172.

%K nonn

%O 1,1

%A _Bob Selcoe_, Mar 21 2017

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 May 29 14:24 EDT 2024. Contains 372952 sequences. (Running on oeis4.)