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
M. F. Hasler, Table of n, a(n) for n = 1..313
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
KEYWORD
nonn
AUTHOR
Eric Angelini and M. F. Hasler, Apr 15 2012
STATUS
approved