OFFSET
1,2
LINKS
Paolo P. Lava, Table of n, a(n) for n = 1..132
FORMULA
a(1) = 1; a(2) = 2; a(3) = 2; a(4) = 1; a(n) = (a(n - 4) + 1 - ((-1)^a(a(n - 1)) + 1)*(a(a(n - 1)) - a(a(n - 2)))/2).
MAPLE
with(numtheory);
P:=proc(i)
local a, n;
a:=array(1..150); a[1]:=1; print(a[1]); a[2]:=2; print(a[2]); a[3]:=2; print(a[3]); a[4]:=1; print(a[4]);
for n from 5 to i do
a[n]:=(a[n-4]+1-((-1)^a[a[n-1]]+1)*(a[a[n-1]]-a[a[n-2]])/2); print(a[n]);
od; end:
P(132); # Paolo P. Lava, Mar 13 2012
MATHEMATICA
a[1] = 1; a[2] = 2; a[3] = 2; a[4] = 1;
a[n_] := a[n] = (a[n - 4] + 1 - ((-1)^a[a[n - 1]] + 1)*(a[a[n - 1]] - a[a[n - 2]])/2);
Table[a[n], {n, 1, 100}]
CROSSREFS
KEYWORD
sign,fini,full
AUTHOR
Roger L. Bagula, Apr 21 2008
STATUS
approved