A026136 Lexicographically earliest permutation of the positive integers such that |a(n)-n| = [a(n)/2].
1, 3, 2, 7, 9, 4, 5, 15, 6, 19, 21, 8, 25, 27, 10, 11, 33, 12, 13, 39, 14, 43, 45, 16, 17, 51, 18, 55, 57, 20, 61, 63, 22, 23, 69, 24, 73, 75, 26, 79, 81, 28, 29, 87, 30, 31, 93, 32, 97, 99, 34, 35, 105, 36, 37, 111, 38, 115, 117, 40, 41, 123
Offset: 1
Keywords
Links
- Sean A. Irvine, Table of n, a(n) for n = 1..10000
- F. M. Dekking, Permutations of N generated by left-right filling algorithms, arXiv:2001.08915 [math.CO], 2020.
- Sean A. Irvine, Java program (github)
- Index entries for sequences that are permutations of the natural numbers
Programs
-
Mathematica
Block[{a, nn = 123}, a[1] = 1; Do[If[! IntegerQ[a[#1]], Set[a[#1], i], Set[a[#2], i]] & @@ {i - #, i + #} &@ Floor[i/2], {i, nn}]; TakeWhile[Array[a[#] &, nn], IntegerQ]] (* Michael De Vlieger, Apr 16 2020 *)
-
PARI
seq(n)={my(a=vector(n)); a[1]=1; for(i=2, 2*n, my(h=i\2); if(!a[i-h], a[i-h]=i, if(i+h<=n, a[i+h]=i))); a} \\ Andrew Howroyd, Oct 15 2019
-
Python
import math A026136 ={1:1} for n in range(2,3000): h=math.floor(n/2) L=n-h R=n+h if not L in A026136 : A026136[L]=n else : A026136[R]=n for n in range(1,2000): if n in A026136: print(str(n) + " "+ str(A026136[n])) else: break # R. J. Mathar, Aug 26 2019
Extensions
Edited by N. J. A. Sloane, Jan 31 2020
New name from Peter Munn, Dec 30 2021
Comments