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!)
A329423 Each term is visited once according to the rule: go left (resp. right) a(n) places if a(n) is prime (resp. not prime), starting at a(1) = 1. Choose a(n) along this journey as the largest possible prime, or else the smallest possible composite, not occurring earlier and compatible with these rules. 2
1, 4, 6, 8, 9, 3, 12, 14, 5, 21, 25, 7, 20, 10, 51, 16, 26, 22, 11, 15, 34, 2, 28, 17, 63, 42, 48, 33, 36, 32, 13, 18, 23, 60, 19, 24, 52, 91, 45, 29, 69, 55, 27, 39, 66, 58, 116, 78, 85, 37, 30, 105, 94, 90, 35, 75, 81, 77, 112, 43, 31, 41, 65, 106, 38, 50, 72, 44, 141, 47, 133, 180, 100, 150, 49, 121, 168, 128, 110 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
More formally: from index i, move to index i - a(i), resp. to i + a(i), if a(i) is prime, resp. not prime.
The sequence is conjectured to be a permutation of the positive integers.
See A330154 for the lexicographic earliest variant, rather than choosing the largest possible prime (and choosing terms following the journey).
LINKS
Hugo Pfoertner, Table of n, a(n) for n = 1..10000 (first 1138 terms from Jean-Marc Falcoz)
EXAMPLE
At index i = 1, a(1) = 1 is the smallest available number and possible since it drives to the right. This implies a move of a(1) = 1 place to the right, i.e., to index i = 2.
Then a(2) cannot be 2 or a larger prime, since this would imply a move too far to the left, so we choose the smallest available composite number, a(2) = 4. This takes us 4 places further to the right, to index 2 + 4 = 6.
Then a(6) can be equal to the prime 3, but not 5 which would drive back to a(1) and create a loop, preventing from visiting all terms. This leads to index 6 - 3 = 3.
Then a(3) cannot be 2 which would lead to already visited a(1), nor a larger prime which would take too far to the left. So a(3) = 6, the smallest available composite number. This leads to index 3 + 6 = 9.
Here a(9) can be a prime, the largest possible choice is a(9) = 5, leading to index 9 - 5 = 4.
Now a(4) cannot be 2 nor 3 nor a larger prime. Therefore a(4) = 8, the smallest available composite number. This leads to index 4 + 8 = 12.
PROG
(PARI) upto(N)={ my(U=[1], V=[2], f(k)=(-1)^isprime(k)*k, add(V, t)=if(V[1]+1<t, setunion(V, [t]), V[1]=t; while(#V>1&&V[2]==V[1]+1, V=V[^1]); V), A=Vec(1, N), done=1, n=1, k, t); while(n<=N||N>=n=valuation(done+1, 2), until(!A[n]|| N < n+=f(A[n]), bittest(done, n)&&(n=oo)&&break; done+=1<<n); n>N&& next; k=n-V[1]; while(U[1]<k=precprime(k-1), setsearch(U, k)|| setsearch(V, t=n-k)|| break); U[1]<k|| forcomposite(k=U[1]+1, oo, setsearch(U, k)|| setsearch(V, t=n+k)|| t<=V[1]|| break); U=add(U, A[n]=abs(t-n)); V=add(V, n=t)); print("Terms > "V[1]" may be incorrect."); A} \\ Use upto(600)[1..90] to get the displayed DATA, for smaller N, terms from a(72) = 180 on may be incorrect. - M. F. Hasler, Dec 05 2019
CROSSREFS
Sequence in context: A330384 A077649 A308375 * A132025 A200363 A249748
KEYWORD
nonn,look
AUTHOR
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 23:26 EDT 2024. Contains 371917 sequences. (Running on oeis4.)