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!)
A330614 The sequence (a(n) - a(n+1); n such that a(n) is prime) yields the original sequence: lexicographically earliest sequence of distinct positive integers with this property and no two nonprime terms in a row. 2
1, 5, 4, 11, 6, 13, 9, 19, 8, 29, 23, 10, 31, 22, 37, 18, 41, 33, 43, 14, 47, 24, 59, 49, 61, 30, 67, 45, 53, 16, 73, 55, 79, 38, 83, 50, 71, 28, 89, 75, 101, 54, 109, 85, 103, 44, 97, 48, 107, 46, 149, 119, 127, 60, 113, 68, 131, 78, 137, 121, 139, 66, 151, 96, 163, 84, 167, 129, 157, 74, 173, 123, 179, 108, 181, 153, 191, 102, 193, 118, 199, 98, 197, 143, 223, 114, 211, 126 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
Not a permutation: some numbers (2, 3, 7, 12, 15, 17, 20, ...) will never appear, these are now listed as A330593.
Can be computed in an "almost greedy" manner using the following two rules:
(1) A prime a(n) = p is always followed by a(n+1) = p - a(N(n)), where N(n) is the number of primes in {a(1), ..., a(n)}. If this a(n+1) > 0 is composite and did not occur earlier, then all terms up to this one are guaranteed to be correct.
(2) A nonprime a(n) is followed by a(n+1) = the next available prime p such that a(n+2) = p - a(N(n)+1) > 0 does not occur earlier and does not lead to an impossible successor (negative or repeated term) through rule (1) in case it is prime. If this happens, the next larger prime must be chosen.
The strongly oscillating graph of this sequence is the union of approximately linear subgraphs G(k), k = 1, 2, 3..., corresponding to subsequences S(k) given as local maxima resp. minima (depending on the parity of k) of the terms not in one of the earlier subsequences. The graphs G(k), k > 2, lie quite precisely in the middle between the two preceding graphs G(k-1) and G(k-2) and have a slope roughly equal to the average of the two "preceding" slopes: e.g., when G(1) has a slope of about 4.0 near n = 10^3, G(2) has a slope of about 2.0, G(3) has a slope of about 3.0, G(4) has a slope of about 2.5, etc.
The subsequences S(k) correspond to roughly every other of the remaining terms, the indices corresponding to their terms are almost always separated by a gap of 2^k and they have density 2^k in range(A330614) = A000027 \ A330593. (S(1) is the subsequence of primes without a(11) = 23. One might also take S(1) as the subsequence of primes, which would only move a(11) = 23 from S(3) to S(1) and a(12) = 10 from S(2) to S(10).) See the link to the OEIS wiki page for more.
Among the first 10^4 terms, a(11) = 23 is the only prime that follows another prime. Are there other such terms? - M. F. Hasler, Dec 27 2019
LINKS
Eric Angelini, Phenix seq by (prime-next term) operation, SeqFan list, Dec 25 2019.
M. F. Hasler, A330614 (more details), OEIS wiki, Dec 30 2019.
FORMULA
For n < 10^4, a(n) is prime <=> n <= 10 and even or n >= 11 and odd.
EXAMPLE
a(1) = 1 must be followed by a prime a(2) = p, but such that a(2) - a(3) = a(1), i.e., p - a(3) = 1 or p - 1 = a(3), and such that this does not produce a contradiction. Indeed, p = 2 is impossible since this would require a(3) = 1 which already occurred earlier. Also, p = 3 would require a(3) = 2, and then a(3) - a(4) = a(2) or 2 - a(4) = 3, also impossible. Therefore a(2) = 5 is the smallest possible choice.
Since a(2) is prime, a(3) is given by the rule that a(2) - a(3) must reproduce the first term of the sequence, a(1) = 1, whence a(3) = a(2) - 1 = 4.
a(3) = 4 must be followed by a prime, but we see that 2 and 3 are not possible: the first try would be 7, which then ought to be followed by 2, leading again to a "contradiction" (no possible successor), so it turns out that a(4) = 11 is the smallest possible choice.
PROG
(PARI) A330614_upto(N=99, show=0/*set to 1 for verbose output*/)={my(i=1, U=[], A=List(i)); for(n=1, N, U=setunion(U, [A[n]]); show&& printf("a(%d) = %d, ", n, A[n]); #A>n || listput(A, 0); if( isprime(A[n]), if( !setsearch(U, A[n+1] = A[n] - A[i] ) && A[n+1] > 0, i++; next, show&& print1("no, "); until(!isprime(A[n]) || !i--, U=setminus(U, [A[n]]); A[n+1]=0; n--))); forprime( k=A[n+1]+1, oo, !setsearch(U, k) && !setsearch(U, k-A[i]) && [A[n+1]=k, break])); while(!A[#A] || isprime(A[#A]), listpop(A)); Vec(A)}
CROSSREFS
Cf. A000040 (primes), A018252 (nonprimes).
Cf. A330593: positive integers which do not appear in this sequence.
Sequence in context: A360682 A089520 A163524 * A051552 A165367 A166549
KEYWORD
nonn,look
AUTHOR
Eric Angelini and M. F. Hasler, Dec 25 2019
STATUS
approved

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 23 20:33 EDT 2024. Contains 371916 sequences. (Running on oeis4.)