%I #17 Sep 11 2024 02:26:59
%S 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,
%T 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,
%U 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
%N a(1) = a(2) = 1, a(3) = 2, thereafter a(n) = abs(a(n-1) - a(n-2) - a(n-3)).
%H Reinhard Zumkeller, <a href="/A080096/b080096.txt">Table of n, a(n) for n = 1..10000</a>
%F For n>=3 Max( a(k) : 1<=k<=n ) = floor ( sqrt(n+4)).
%F Special cases: a(n^2 + 4*n - 1) = 0 and a(n^2 - 4) = n.
%F a(A028557(n)) = a(A028557(n+1)).
%F Sum_{k=(n-1)^2 .. n^2} a(k) = n^2.
%t nxt[{a_,b_,c_}]:={b,c,Abs[c-b-a]}; NestList[nxt,{1,1,2},110][[All,1]] (* _Harvey P. Dale_, Nov 14 2021 *)
%o (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))
%o (Haskell)
%o a080096 n = a080096_list !! (n-1)
%o a080096_list = 1 : 1 : 2 : zipWith3 (\u v w -> abs (w - v - u))
%o a080096_list (tail a080096_list) (drop 2 a080096_list)
%o -- _Reinhard Zumkeller_, Oct 11 2014
%o (Magma)
%o m:=120;
%o 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]];
%o [A080096[n]: n in [1..m]]; // _G. C. Greubel_, Sep 11 2024
%o (SageMath)
%o @CachedFunction
%o def a(n): # a = A080096
%o if n<4: return int((n+1)//2)
%o else: return abs(a(n-1)-a(n-2)-a(n-3))
%o [a(n) for n in range(1,101)] # _G. C. Greubel_, Sep 11 2024
%Y Cf. A028347, A028557, A077623, A077653, A079623, A079624, A088226.
%K nonn
%O 1,3
%A _Benoit Cloitre_, Jan 28 2003