f1 = FoldList[Plus, #, 3 Mod[Range[0, 2 (# - 2)], 2] - 2] &
f1 @ 5
{5, 3, 4, 2, 3, 1, 2, 0}
f1 @ 4
{4, 2, 3, 1, 2, 0}
Also
f2 = Accumulate[Prepend[#]@{-2,Accumulate 1}@ Prepend[#] @ (3 Mod[Range[0, 2 (# - 2)], 2] - 2) &;
f2 @ 5
{5, 3, 4, 2, 3, 1, 2, 0}
f2 @ 4
{4, 2, 3, 1, 2, 0}