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

%I #34 Nov 26 2020 19:25:43

%S 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,

%T 48,33,36,32,13,18,23,60,19,24,52,91,45,29,69,55,27,39,66,58,116,78,

%U 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

%N 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.

%C More formally: from index i, move to index i - a(i), resp. to i + a(i), if a(i) is prime, resp. not prime.

%C The sequence is conjectured to be a permutation of the positive integers.

%C See A330154 for the lexicographic earliest variant, rather than choosing the largest possible prime (and choosing terms following the journey).

%H Hugo Pfoertner, <a href="/A329423/b329423.txt">Table of n, a(n) for n = 1..10000</a> (first 1138 terms from Jean-Marc Falcoz)

%e 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.

%e 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.

%e 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.

%e 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.

%e Here a(9) can be a prime, the largest possible choice is a(9) = 5, leading to index 9 - 5 = 4.

%e 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.

%o (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

%Y Cf. A103825, A330154.

%K nonn,look

%O 1,2

%A _Eric Angelini_ and _Jean-Marc Falcoz_, Nov 30 2019

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 August 28 11:51 EDT 2024. Contains 375504 sequences. (Running on oeis4.)