A026177 For n >= 2, let h=floor(n/2), L=n-h, R=n+h; then a(R)=n if n odd or a(L) already defined, otherwise a(L)=n.
1, 4, 2, 3, 10, 12, 5, 16, 6, 7, 22, 8, 9, 28, 30, 11, 34, 36, 13, 40, 14, 15, 46, 48, 17, 52, 18, 19, 58, 20, 21, 64, 66, 23, 70, 24, 25, 76, 26, 27, 82, 84, 29, 88, 90, 31, 94, 32, 33, 100, 102, 35, 106, 108, 37, 112, 38, 39, 118, 120, 41
Offset: 1
Keywords
Links
- Andrew Howroyd, 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.
Crossrefs
Programs
-
Mathematica
Array[If[Mod[#/3^IntegerExponent[#, 3], 3] == 1, Ceiling[2 #/3], 2 #] &, 61] (* Michael De Vlieger, Feb 08 2020 *)
-
PARI
seq(n)={my(a=vector(n)); a[1]=1; for(i=2, 2*n, my(h=i\2); if(i%2==0&&!a[i-h], a[i-h]=i, if(i+h<=n, a[i+h]=i))); a} \\ Andrew Howroyd, Oct 15 2019
-
PARI
a(n) = if((n/3^valuation(n,3))%3==1, ceil(2*n/3), 2*n); \\ Kevin Ryde, Feb 06 2020
Formula
From Kevin Ryde, Feb 06 2020: (Start)
a(n) = ceiling(2n/3) if A060236(n)=1, otherwise a(n) = 2n, where A060236(n) is the lowest non-0 ternary digit of n.
a(n) = ceiling(2n / 3^A137893(n)).
a(3n) = 3*a(n) - (1 if n==1 (mod 3)).
(End)
Extensions
Edited by N. J. A. Sloane, Feb 05 2020
Comments