%I #23 Apr 18 2023 07:14:50
%S 1,2,3,5,4,7,6,8,11,9,10,12,13,14,15,17,16,18,19,23,29,20,21,31,22,37,
%T 24,41,25,43,26,27,47,28,30,53,32,59,33,34,35,61,67,71,36,38,73,39,40,
%U 79,83,42,44,89,97,45,101,46,103,48,49,107,109,50
%N Lexicographically earliest permutation of the positive integers such that a(n+a(n)) is prime for all n.
%C "Lexicographically earliest" means that a(n) is chosen as small as possible, in the order of increasing n, without leading to a contradiction. "Permutation" means that no integer may appear more than once, and together with the former prescription, every integer will indeed appear.
%C Existence of the sequence is guaranteed since terms can be filled in one after the other, and each time the place n+a(n) (which comes later) is required to be filled with a prime. This does not prevent from filling other places with primes. Since at each step the smallest available number is used, the primes as well as the composites appear in their natural order.
%C It appears that the primes are exactly the "early birds" of this sequence, i.e., the terms such that a(n)>n, except for {2, 3, 13, 19} which appear in their natural position. - _M. F. Hasler_, Oct 09 2013
%H Neal Gersh Tolunsky, <a href="/A230086/b230086.txt">Table of n, a(n) for n = 1..5000</a>
%H Eric Angelini, <a href="http://list.seqfan.eu/oldermail/seqfan/2013-October/011747.html">a(a(n) + n) is prime</a>, SeqFan list, Oct 08 2013.
%H <a href="/index/Se#self-referencing_sequences">Index to the OEIS: Entries related to self-referencing sequences</a>.
%o (PARI) {u=0;a=vector(1000);for(i=1,#a,a[i]>0 && next;for(x=1,9e9,(!a[i] || isprime(x)) && !bittest(u,x) && (a[i]=x) && break);u+=1<<a[i];i+a[i]<=#a && a[i+a[i]]=-1);vecextract(a,"..100")}
%K nonn
%O 1,2
%A _Eric Angelini_ and _M. F. Hasler_, Oct 08 2013