[go: up one dir, main page]

login
A063733
A variant of Recamán's sequence: a(0)=1, a(n) = a(n-1)-(n-1) if positive and new, else a(n) = a(n-1)+(n-1).
11
1, 1, 2, 4, 7, 3, 8, 14, 21, 13, 22, 12, 23, 11, 24, 10, 25, 9, 26, 44, 63, 43, 64, 42, 19, 43, 18, 44, 17, 45, 16, 46, 15, 47, 80, 114, 79, 115, 78, 40, 79, 39, 80, 38, 81, 37, 82, 36, 83, 35, 84, 34, 85, 33, 86, 32, 87, 31, 88, 30, 89, 29, 90, 28, 91, 27
OFFSET
0,3
FORMULA
a(n+1) = A005132(n) - 1; A005132 is Recamán's sequence. - Franklin T. Adams-Watters, Mar 12 2010
MATHEMATICA
a[0] = 1; a[n_] := a[n] = If[an = a[n-1] - (n-1); an > 0 && FreeQ[Array[a, n-1], an], an, a[n-1] + (n-1)]; Table[a[n], {n, 0, 65}] (* Jean-François Alcover, Feb 18 2018 *)
PROG
(Haskell)
a063733 n = a063733_list !! n
a063733_list = 1 : f 0 [1] where
f x ys@(y:_) | u > 0 && u `notElem` ys = u : f (x + 1) (u : ys)
| otherwise = v : f (x + 1) (v : ys)
where u = y - x; v = x + y
-- Reinhard Zumkeller, Jul 02 2015
(Python)
l=[1]
for n in range(1, 101):
x = l[n - 1] - (n - 1)
if x > 0 and x not in l:
l.append(x)
else:
l.append(l[n - 1] + (n - 1))
print(l) # Indranil Ghosh, Jun 02 2017
CROSSREFS
See A005132, which is the main entry for this sequence. A063753 = 1 + A005132. A row of A066201. Also a row of A066202.
See also A078943.
Cf. A141126.
Sequence in context: A100707 A302663 A078943 * A187089 A141330 A239324
KEYWORD
nonn,nice,easy,look
AUTHOR
N. J. A. Sloane, Sep 05 2001
STATUS
approved