cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

Original entry on oeis.org

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
Offset: 1

Views

Author

Eric Angelini and Jean-Marc Falcoz, Nov 30 2019

Keywords

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).

Examples

			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.
		

Crossrefs

Programs

  • PARI
    upto(N)={ my(U=[1], V=[2], f(k)=(-1)^isprime(k)*k, add(V,t)=if(V[1]+11&&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&& next; k=n-V[1]; while(U[1] "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