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
AUTHOR
EXTENSIONS
Edited by N. J. A. Sloane, Jan 31 2020
STATUS
approved