login
A123144
a(1) = 1, a(n) = a(n-1) if n = 1 (mod 3), otherwise n*a(n-1).
2
1, 2, 6, 6, 30, 180, 180, 1440, 12960, 12960, 142560, 1710720, 1710720, 23950080, 359251200, 359251200, 6107270400, 109930867200, 109930867200, 2198617344000, 46170964224000, 46170964224000, 1061932177152000, 25486372251648000, 25486372251648000
OFFSET
1,2
COMMENTS
Without duplicates this sequence is A293653.
LINKS
MAPLE
a:= proc(n) option remember; `if`(n=0, 1,
`if`(irem(n, 3)=1, 1, n)*a(n-1))
end:
seq(a(n), n=1..32); # Alois P. Heinz, Jul 16 2023
MATHEMATICA
a[n_]:= a[n]= If[n==1, 1, If[Mod[n, 3]==1, a[n-1], n*a[n-1]]];
Table[a[n], {n, 30}]
nxt[{n_, a_}]:={n+1, If[Mod[n+1, 3]==1, a, a(n+1)]}; Transpose[NestList[nxt, {1, 1}, 20]][[2]] (* Harvey P. Dale, Jul 22 2014 *)
PROG
(Magma)
function a(n)
if n eq 1 then return 1;
elif (n mod 3) eq 1 then return a(n-1);
else return n*a(n-1);
end if;
end function;
[a(n): n in [1..40]]; // G. C. Greubel, Jul 16 2023
(SageMath)
def a(n): # A123144
if (n==1): return 1
elif (n%3==1): return a(n-1)
else: return n*a(n-1)
[a(n) for n in range(1, 41)] # G. C. Greubel, Jul 16 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Roger L. Bagula, Oct 01 2006
EXTENSIONS
Edited by N. J. A. Sloane, Oct 04 2006
STATUS
approved