login
A137419
a(n) = (a(n - 4) + 1 - ((-1)^a(a(n - 1)) + 1)*(a(a(n - 1)) - a(a(n - 2)))/2).
1
1, 2, 2, 1, 2, 2, 3, 2, 3, 3, 4, 3, 3, 4, 5, 3, 4, 5, 5, 4, 5, 5, 6, 5, 6, 6, 7, 6, 8, 7, 8, 8, 9, 8, 10, 9, 10, 9, 11, 9, 11, 9, 12, 10, 12, 10, 13, 11, 12, 11, 13, 12, 13, 12, 14, 12, 14, 12, 15, 13, 15, 13, 16, 14, 15, 14, 18, 15, 16, 15, 19, 16, 17, 15, 20, 18, 18, 16, 21, 19, 19, 17, 23
OFFSET
1,2
LINKS
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
Sequence in context: A343189 A271775 A143999 * A057536 A245574 A245573
KEYWORD
sign,fini,full
AUTHOR
Roger L. Bagula, Apr 21 2008
STATUS
approved