OFFSET
1,2
COMMENTS
Variation (1) on Recamán's sequence A005132.
a(A134931(n-1)) = 1. - Reinhard Zumkeller, Jan 31 2013
LINKS
N. J. A. Sloane, First 10000 terms
Nick Hobson, Python program for this sequence
Kival Ngaokrajang, scatter plot in log-log scale looks, for both this sequence and A211346.
FORMULA
This is a concatenation S_0, S_1, S_2, ... where S_i = [b_0, b_1, ..., b_{k-1}], k=5*3^i, with b_0 = 1, b_{2j} = k+j, b_{2j+1} = (k+1)/2-j. E.g., S_0 = [1, 3, 6, 2, 7].
For any m>=1, for k such that 5*3^k+3>12m, a((5*3^k+3-12*m)/6)= m. For example, for k>=1, a((5*3^k-9)/6) = 1. - Benoit Cloitre, Oct 31 2002
MAPLE
MATHEMATICA
a[1]=1; a[n_]:=a[n]=If[a[n-1]>n, a[n-1]-n, a[n-1]+n]; Table[a[i], {i, 70}] (* Harvey P. Dale, Apr 01 2011 *)
nxt[{n_, a_}]:={n+1, If[a>n+1, a-n-1, a+n+1]}; NestList[nxt, {1, 1}, 70][[All, 2]] (* Harvey P. Dale, Jun 01 2019 *)
PROG
(PARI) a(n)=if(n<2, 1, a(n-1)-if(sign(n-a(n-1))+1, -1, 1)*n);
(Haskell)
a046901 n = a046901_list !! (n-1)
a046901_list = scanl1 (\u v -> if u > v then u - v else u + v) [1..]
-- Reinhard Zumkeller, Dec 07 2015, Jan 31 2013
CROSSREFS
KEYWORD
AUTHOR
STATUS
approved