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.
%I A026166 #35 Jul 03 2020 07:13:59 %S A026166 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 A026166 52,19,56,58,21,62,64,23,24,70,25,74,76,27,80,82,29,30,88,31,32,94,33, %U A026166 98,100,35,36,106,37,38,112,39,116,118,41,42 %N A026166 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 A026166 Every positive integer occurs exactly once. The inverse permutation of the positive integers is given by A026167. - _Clark Kimberling_, Oct 20 2019 %H A026166 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 A026166 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 A026166 |a(n)-n| = floor((1/2)*(a(n)-1)). %F A026166 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 A026166 a[1] = 1; z = 300; %t A026166 Do[{L, R} = {n - #, n + #} &[Floor[(n - 1)/2]]; %t A026166 If[! Head[a[L]] === Integer, a[L] = n, a[R] = n], {n, 2, z}]; %t A026166 a026166 = Most[Last[ %t A026166 Last[Reap[NestWhile[# + 1 &, 1, Head[Sow[a[#]]] === Integer &]]]]]; %t A026166 ListPlot[a026166] (* _Peter J. C. Moses_, Oct 20 2019 *) %o A026166 (Python) %o A026166 A026166 = {1: 1} %o A026166 for n in range(2, 1000): %o A026166 h=(n-1)//2 %o A026166 L=n-h %o A026166 R=n+h %o A026166 if not L in A026166 : %o A026166 A026166[L]=n %o A026166 else : %o A026166 A026166[R]=n %o A026166 for n in range(1,2000): %o A026166 if n in A026166: %o A026166 print(A026166[n], end=',') %o A026166 else: %o A026166 break %o A026166 # _R. J. Mathar_, Aug 26 2019 %o A026166 (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 A026166 Cf. A026167, A026182, A026198, A026202. %K A026166 nonn %O A026166 1,2 %A A026166 _Clark Kimberling_ %E A026166 Edited by _N. J. A. Sloane_, Jan 31 2020