login

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”).

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)).
12
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, 52, 19, 56, 58, 21, 62, 64, 23, 24, 70, 25, 74, 76, 27, 80, 82, 29, 30, 88, 31, 32, 94, 33, 98, 100, 35, 36, 106, 37, 38, 112, 39, 116, 118, 41, 42
OFFSET
1,2
COMMENTS
Every positive integer occurs exactly once. The inverse permutation of the positive integers is given by A026167. - Clark Kimberling, Oct 20 2019
LINKS
Clark Kimberling, Table of n, a(n) for n = 1..10000 (terms 1..1502 from R. J. Mathar)
F. M. Dekking, Permutations of N generated by left-right filling algorithms, arXiv:2001.08915 [math.CO], 2020.
FORMULA
|a(n)-n| = floor((1/2)*(a(n)-1)).
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
MATHEMATICA
a[1] = 1; z = 300;
Do[{L, R} = {n - #, n + #} &[Floor[(n - 1)/2]];
If[! Head[a[L]] === Integer, a[L] = n, a[R] = n], {n, 2, z}];
a026166 = Most[Last[
Last[Reap[NestWhile[# + 1 &, 1, Head[Sow[a[#]]] === Integer &]]]]];
ListPlot[a026166] (* Peter J. C. Moses, Oct 20 2019 *)
PROG
(Python)
A026166 = {1: 1}
for n in range(2, 1000):
h=(n-1)//2
L=n-h
R=n+h
if not L in A026166 :
A026166[L]=n
else :
A026166[R]=n
for n in range(1, 2000):
if n in A026166:
print(A026166[n], end=', ')
else:
break
# R. J. Mathar, Aug 26 2019
(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
CROSSREFS
KEYWORD
nonn
EXTENSIONS
Edited by N. J. A. Sloane, Jan 31 2020
STATUS
approved