OFFSET
1,2
FORMULA
a(1)=1; for n > 1,
a(n) = a(n-1) * n if n mod 3 = 2,
a(n-1) - n if n mod 3 = 0,
a(n-1) + n if n mod 3 = 1.
EXAMPLE
a(2) = 1 * 2 = 2;
a(3) = 2 - 3 = -1;
a(4) = -1 + 4 = 3.
MATHEMATICA
FoldList[If[Mod[#2, 3]==2, #1*#2, If[Mod[#2, 3]==0, #1-#2, #1+#2]]&, 1, Range[2, 33]] (* James C. McMahon, Oct 09 2023 *)
PROG
(Python)
from itertools import count, islice
def A362272_gen(): # generator of terms
yield (a:=1)
for n in count(2, 3):
yield (a:=a*n)
yield (a:=a-n-1)
yield (a:=a+n+2)
CROSSREFS
KEYWORD
sign
AUTHOR
James C. McMahon, Apr 19 2023
STATUS
approved