OFFSET
1,6
COMMENTS
Conjecture: a(n) = m/2 where m is the smallest even distance from n to a square. - Ralf Stephan, Sep 23 2013
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
FORMULA
a(k^2 + 2*m + 2) = k-m and a(k^2 + 2*m + 1) = m, for k >= 0 and 0 <= m <= k.
MATHEMATICA
RecurrenceTable[{a[1]==a[2]==0, a[3]==1, a[n]==Abs[a[n-1]-a[n-2]-a[n-3]]}, a, {n, 110}] (* Harvey P. Dale, Apr 13 2012 *)
PROG
(PARI) a(n)=t=sqrtint(n); if((n-t*t)%2==0, (n-t*t)/2, ((t+1)^2-n)/2) \\ Ralf Stephan, Sep 23 2013
(Haskell)
a088226 n = a088226_list !! (n-1)
a088226_list = 0 : 0 : 1 : zipWith3 (\u v w -> abs (w - v - u))
a088226_list (tail a088226_list) (drop 2 a088226_list)
-- Reinhard Zumkeller, Oct 11 2014
(Magma)
m:=120;
A088226:=[n le 3 select Floor((n-1)/2) else Abs(Self(n-1) - Self(n-2) - Self(n-3)): n in [1..m+5]];
[A088226[n]: n in [1..m]]; // G. C. Greubel, Sep 11 2024
(SageMath)
@CachedFunction
def a(n): # a = A088226
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
CROSSREFS
KEYWORD
nonn
AUTHOR
Benoit Cloitre, Nov 04 2003
STATUS
approved