OFFSET
1,2
COMMENTS
a(n) = 1 correspond to n = A058481(m). - Bill McEachen, Aug 31 2023
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
FORMULA
If 3^n>2*m>= 2*3^(n-1); a(3^n-2*m) = m; if 3^n>2*m+1>=2*3^(n-1)+1 a(3^n-2*m-1) = 3^n - m; special case of partial sum: sum(k=1, 3^n, a(k)) = (3/8)*(9^n-1) + (3^(n+1)-1)/2.
Conjecture: a(n) = -a(n-1)+a(n-2)+a(n-3) for n>5. G.f.: -x*(27*x^28 +54*x^27 +27*x^26 +9*x^10 +18*x^9 +9*x^8 +3*x^4 +6*x^3 +5*x^2 +4*x +1) / ((x -1)*(x +1)^2). - Colin Barker, Feb 25 2013
EXAMPLE
a(2) = a(1)+sign(2-a(1))*2 = 1 + 2 = 3.
MATHEMATICA
RecurrenceTable[{a[1]==1, a[n]==a[n-1]+n Sign[n-a[n-1]]}, a[n], {n, 80}] (* Harvey P. Dale, Jun 14 2011 *)
PROG
(Haskell)
a076217 n = a076217_list !! (n-1)
a076217_list = 1 : zipWith (+) a076217_list
(zipWith (*) [2..] $ map a057427 $ zipWith (-) [2..] a076217_list)
-- Reinhard Zumkeller, Apr 21 2013
(PARI) alist(N) = my(r, t=0); vector(N, i, t=r=t+i*sign(i-t)); \\ Ruud H.G. van Tol, May 10 2024
CROSSREFS
KEYWORD
AUTHOR
Benoit Cloitre, Nov 03 2002
STATUS
approved