OFFSET
1,2
COMMENTS
Without duplicates this sequence is A293653.
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..632
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