OFFSET
0,4
LINKS
T. D. Noe, Table of n, a(n) for n = 0..10000
FORMULA
a(n) = a(n-1)+a(n-2)-n if a(n-1)+a(n-2)>n, a(n) = a(n-1)+a(n-2) otherwise; a(0) = 0, a(1) = 1.
MATHEMATICA
a[0] = 0; a[1] = 1; a[n_] := a[n] = Block[ {b = a[n - 1] + a[n - 2]}, If[b > n, Return[b - n], Return[b]]]; Table[a[n], {n, 0, 80} ]
nxt[{n_, a_, b_}]:={n+1, b, If[a+b>n+1, a+b-n-1, a+b]}; Transpose[ NestList[ nxt, {1, 0, 1}, 80]][[2]] (* Harvey P. Dale, Sep 04 2013 *)
PROG
(Haskell)
a066949 n = a066949_list !! n
a066949_list = 0 : 1 : f 2 1 0 where
f k x x' | z > k = (z - k) : f (k+1) (z - k) x
| otherwise = z : f (k+1) z x where z = x + x'
-- Reinhard Zumkeller, Oct 17 2011
(Python)
l=[0, 1]
for n in range(2, 101):
x=l[n - 1] + l[n - 2]
if x>n: l.append(x - n)
else: l.append(x)
print(l) # Indranil Ghosh, Jun 03 2017
CROSSREFS
KEYWORD
easy,nonn,nice
AUTHOR
Floor van Lamoen, Jan 25 2002
EXTENSIONS
Edited by Robert G. Wilson v, Jan 31 2002
STATUS
approved