login
a(1) = 1, then add, multiply and subtract 2, 3, 4; 5, 6, 7; ... in that order.
6

%I #22 Oct 11 2023 04:35:06

%S 1,3,9,5,10,60,53,61,549,539,550,6600,6587,6601,99015,98999,99016,

%T 1782288,1782269,1782289,37428069,37428047,37428070,898273680,

%U 898273655,898273681,24253389387,24253389359,24253389388,727601681640,727601681609

%N a(1) = 1, then add, multiply and subtract 2, 3, 4; 5, 6, 7; ... in that order.

%e a(2) = a(1) + 2 = 3, a(3) = 3*3 = 9, a(4) = 9 - 4 = 5, a(5) = 5 + 5 = 10, etc.

%p a := proc(n) if n=1 then 1 elif n mod 3 = 2 then a(n-1)+n elif n mod 3 = 0 then n*a(n-1) elif n mod 3 = 1 then a(n-1)-n else fi end: # _Emeric Deutsch_, Dec 17 2003

%t FoldList[If[Mod[#2, 3]==2, #1+#2, If[Mod[#2, 3]==0, #1*#2, #1-#2]]&, 1, Range[2, 31]] (* _James C. McMahon_, Oct 10 2023 *)

%o (Python)

%o from itertools import count, islice

%o def A077383_gen(): # generator of terms

%o yield (a:=1)

%o for n in count(2,3):

%o yield (a:=a+n)

%o yield (a:=a*(n+1))

%o yield (a:=a-n-2)

%o A077383_list = list(islice(A077383_gen(),20)) # _Chai Wah Wu_, Apr 19 2023

%Y Other operation orders: A077382, A077384, A362269, A362270, A362271, A362272.

%K nonn

%O 1,2

%A _Amarnath Murthy_, Nov 06 2002

%E More terms from _Emeric Deutsch_, Dec 17 2003