OFFSET
1,2
COMMENTS
Also: a(1)=1, a(n) = maximal positive integer < a(n-1) not yet in the sequence, if it exists, else a(n) = 3*a(n-1).
Also: a(1)=1, a(n) = a(n-1) - 1, if a(n-1) - 1 > 0 and has not been encountered so far, else a(n) = 3*a(n-1).
A permutation of the positive integers. The sequence is self-inverse, in that a(a(n)) = n.
FORMULA
G.f.: g(x) = (x(1-2x)/(1-x) + 3x^2*f'(x^(5/2)) + (5/9)*(f'(x^(1/2)) - 3x - 1))/(1-x) where f(x) = Sum_{k>=0} x^(3^k) and f'(z) = derivative of f(x) at x = z.
a(n) = 4*3^(r/2) - 2 - n if both r and s are even, else a(n) = 7*3^((s-1)/2) - 2 - n, where r = ceiling(2*log_3((2n+3)/5)), s = ceiling(2*log_3((2n+3)/3) - 1).
a(n) = (3^floor(1 + (k+1)/2) + (5*3^floor(k/2) - 4)/2 - n, where k=r if r is odd, else k=s (with respect to r and s above; formally, k = ((r+s) - (r-s)*(-1)^r)/2).
CROSSREFS
KEYWORD
nonn
AUTHOR
Hieronymus Fischer, Aug 24 2007, Sep 15 2007, Sep 23 2007
STATUS
approved