Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #35 Jul 03 2020 07:13:59
%S 1,2,4,3,8,10,5,6,16,7,20,22,9,26,28,11,12,34,13,14,40,15,44,46,17,18,
%T 52,19,56,58,21,62,64,23,24,70,25,74,76,27,80,82,29,30,88,31,32,94,33,
%U 98,100,35,36,106,37,38,112,39,116,118,41,42
%N For n >= 2, let h=floor((n-1)/2), L=n-h, R=n+h; then a(L)=n if a(L) not yet defined, otherwise a(R)=n; thus |a(n)-n| = floor((1/2)*(a(n)-1)).
%C Every positive integer occurs exactly once. The inverse permutation of the positive integers is given by A026167. - _Clark Kimberling_, Oct 20 2019
%H Clark Kimberling, <a href="/A026166/b026166.txt">Table of n, a(n) for n = 1..10000</a> (terms 1..1502 from R. J. Mathar)
%H F. M. Dekking, <a href="https://arxiv.org/abs/2001.08915">Permutations of N generated by left-right filling algorithms</a>, arXiv:2001.08915 [math.CO], 2020.
%F |a(n)-n| = floor((1/2)*(a(n)-1)).
%F This formula does not permit us to calculate the n-th term of the sequence, since the equation |x-n| = floor((1/2)*(x-1)) has at least 2 integer solutions for all n. - _Michel Dekking_, Nov 26 2019
%t a[1] = 1; z = 300;
%t Do[{L, R} = {n - #, n + #} &[Floor[(n - 1)/2]];
%t If[! Head[a[L]] === Integer, a[L] = n, a[R] = n], {n, 2, z}];
%t a026166 = Most[Last[
%t Last[Reap[NestWhile[# + 1 &, 1, Head[Sow[a[#]]] === Integer &]]]]];
%t ListPlot[a026166] (* _Peter J. C. Moses_, Oct 20 2019 *)
%o (Python)
%o A026166 = {1: 1}
%o for n in range(2, 1000):
%o h=(n-1)//2
%o L=n-h
%o R=n+h
%o if not L in A026166 :
%o A026166[L]=n
%o else :
%o A026166[R]=n
%o for n in range(1,2000):
%o if n in A026166:
%o print(A026166[n], end=',')
%o else:
%o break
%o # _R. J. Mathar_, Aug 26 2019
%o (PARI) seq(n)={my(a=vector(n)); a[1]=1; for(i=1, 2*n-1, my(h=(i-1)\2); if(!a[i-h], a[i-h]=i, if(i+h<=n, a[i+h]=i))); a} \\ _Andrew Howroyd_, Oct 15 2019
%Y Cf. A026167, A026182, A026198, A026202.
%K nonn
%O 1,2
%A _Clark Kimberling_
%E Edited by _N. J. A. Sloane_, Jan 31 2020