OFFSET
1,2
COMMENTS
Inverse of A026177.
From Kevin Ryde, Feb 06 2020: (Start)
The formulas below are seen by considering values taken in the inverse A026177. Dekking's case II there is here a(2n) = n when lowest non-0 ternary digit LNZ(n) = A060236(n) = 2, which is LNZ(2n)=1. Otherwise case III is here a(2n+1) = 3n+1 and case IV is here a(2n) = 3n. These can be combined by a floor (the inverse of the ceiling in A026177).
For positive c with LNZ(c)=1, so c = (3j+1)*3^k = A026225, this sequence has a self-similarity in that taking the values which are multiples of c, and dividing them by c, gives the full sequence again. Using the inverse A026177, a(n)=c*m here is located at n = A026177(c*m) = c*A026177(m) - (floor(c/3) if m==1 (mod 3)) since c*m goes to the same bigger or smaller case in A026177 as m does. Then since floor(c/2) < c, values c*m are in the same order as all values m.
(End)
LINKS
Michael De Vlieger, 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.
FORMULA
From Kevin Ryde, Feb 06 2020: (Start)
a(n) = n/2 if n even and A060236(n)=1, otherwise a(n) = floor(3n/2), where A060236(n) is the lowest non-0 ternary digit of n.
a(3n) = 3*a(n) + (1 if n odd).
(End)
MATHEMATICA
Values[Take[#, LengthWhile[Differences@ Keys@ #, # == 1 &]]][[All, 1]] &@ KeySort@ PositionIndex@ Array[If[Mod[#/3^IntegerExponent[#, 3], 3] == 1, Ceiling[2 #/3], 2 #] &, 94] (* or *)
Block[{nn = 63, s}, s = Array[If[Mod[#/3^IntegerExponent[#, 3], 3] == 1, Ceiling[2 #/3], 2 #] &, Ceiling[3 nn/2]]; Array[FirstPosition[s, #][[1]] &, nn]] (* Michael De Vlieger, Feb 08 2020 *)
PROG
(PARI) a(n) = if(n%2 || (n/3^valuation(n, 3))%3==2, floor(3*n/2), n/2);
CROSSREFS
KEYWORD
nonn
AUTHOR
EXTENSIONS
Edited by N. J. A. Sloane, Feb 05 2020
STATUS
approved