login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A080096
a(1) = a(2) = 1, a(3) = 2, thereafter a(n) = abs(a(n-1) - a(n-2) - a(n-3)).
7
1, 1, 2, 0, 3, 1, 2, 2, 1, 3, 0, 4, 1, 3, 2, 2, 3, 1, 4, 0, 5, 1, 4, 2, 3, 3, 2, 4, 1, 5, 0, 6, 1, 5, 2, 4, 3, 3, 4, 2, 5, 1, 6, 0, 7, 1, 6, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 7, 0, 8, 1, 7, 2, 6, 3, 5, 4, 4, 5, 3, 6, 2, 7, 1, 8, 0, 9, 1, 8, 2, 7, 3, 6, 4, 5, 5, 4, 6, 3, 7, 2, 8, 1, 9, 0, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5
OFFSET
1,3
LINKS
FORMULA
For n>=3 Max( a(k) : 1<=k<=n ) = floor ( sqrt(n+4)).
Special cases: a(n^2 + 4*n - 1) = 0 and a(n^2 - 4) = n.
a(A028557(n)) = a(A028557(n+1)).
Sum_{k=(n-1)^2 .. n^2} a(k) = n^2.
MATHEMATICA
nxt[{a_, b_, c_}]:={b, c, Abs[c-b-a]}; NestList[nxt, {1, 1, 2}, 110][[All, 1]] (* Harvey P. Dale, Nov 14 2021 *)
PROG
(PARI) a(n)=local(k, m); if(n<1, 0, k=sqrtint(n+4); m=n+4-k^2; if(m%2, m\2+1, k-m\2))
(Haskell)
a080096 n = a080096_list !! (n-1)
a080096_list = 1 : 1 : 2 : zipWith3 (\u v w -> abs (w - v - u))
a080096_list (tail a080096_list) (drop 2 a080096_list)
-- Reinhard Zumkeller, Oct 11 2014
(Magma)
m:=120;
A080096:=[n le 3 select Floor((n+1)/2) else Abs(Self(n-1) - Self(n-2) - Self(n-3)): n in [1..m+5]];
[A080096[n]: n in [1..m]]; // G. C. Greubel, Sep 11 2024
(SageMath)
@CachedFunction
def a(n): # a = A080096
if n<4: return int((n+1)//2)
else: return abs(a(n-1)-a(n-2)-a(n-3))
[a(n) for n in range(1, 101)] # G. C. Greubel, Sep 11 2024
KEYWORD
nonn
AUTHOR
Benoit Cloitre, Jan 28 2003
STATUS
approved