login
A182164
Start with a(1)=1, if a(n) is prime, jump over a(n) neighbors to the left, else to the right. Fill in the largest possible unused prime, or the least unused composite, such that the next destination is not yet filled.
2
1, 6, 4, 10, 8, 9, 14, 5, 3, 26, 18, 12, 22, 7, 2, 11, 27, 16, 34, 28, 50, 15, 24, 35, 17, 39, 51, 57, 38, 20, 45, 32, 44, 87, 23, 21, 13, 19, 94, 48, 69, 72, 62, 93, 30, 63, 65, 25, 31, 58, 37, 80, 54, 29, 102, 96, 82, 47, 77, 36, 90, 114, 153, 138, 33, 40, 117, 41, 106, 68, 134
OFFSET
1,2
COMMENTS
"Largest possible" means that the prime has to be less than n-1 (to be able to jump over a(n) neighbors to the left) and the place at index n-a(n)-1 has to be vacant. If (and only if) no such prime exists, the "or" clause (filling with composite) applies.
LINKS
E. Angelini, Jumping back and forth (primes and composites), SeqFan list, Apr 15 2012
PROG
(PARI) A182164_list(N_min, debug)= my(L=1 /* least unfilled position */, p=1 /* current position */, u=0 /* used numbers (bitmap) */, a=vector(7*N_min)); a[1]=1; while( while (a[L] , L++) || L<N_min, p += (a[p]+1) * (-1)^isprime(a[p]); forstep( t=p-L, 2, -1, t=precprime(t); !bittest(u, t) && !a[p-t-1] && (u+=1<<a[p]= t) && next(2)); for (t=4, 9e9, bittest(u, t) && next; isprime(t) && next; #a>p+t || a=concat(a, vector(p+t+1-#a)); a[p+t+1] && next; u+=1<<a[p]=t; break)); debug && print("Largest used: ", #a); vecextract(a, 2^(L-1)-1)
CROSSREFS
Sequence in context: A143520 A075450 A145979 * A294093 A257926 A116946
KEYWORD
nonn
AUTHOR
Eric Angelini and M. F. Hasler, Apr 15 2012
STATUS
approved