login
A047905
a(n+1) = a(n) + n (if n is even), a(n+1) = a(n) * n (if n is odd).
8
1, 1, 3, 9, 13, 65, 71, 497, 505, 4545, 4555, 50105, 50117, 651521, 651535, 9773025, 9773041, 166141697, 166141715, 3156692585, 3156692605, 66290544705, 66290544727, 1524682528721, 1524682528745, 38117063218625, 38117063218651
OFFSET
1,3
LINKS
MATHEMATICA
a[0]=1; a[n_]:=a[n]=If[EvenQ[n], a[n-1]+n, a[n-1]n]; Join[{1}, Array[a, 40]] (* Harvey P. Dale, Apr 24 2011 *)
nxt[{n_, a_}]:={n+1, If[EvenQ[n], a+n, a*n]}; NestList[nxt, {1, 1}, 30][[All, 2]] (* Harvey P. Dale, Jul 27 2021 *)
PROG
(Haskell)
a047905 n = a047905_list !! (n-1)
a047905_list = 1 : zipWith uncurry
(cycle [(*), (+)]) (zip a047905_list [1..])
-- Reinhard Zumkeller, Nov 13 2013, May 31 2011
(Python)
a=1
for n in range(1, 33):
print(a, end=", ")
if n&1:
a *= n
else:
a += n
# Alex Ratushnyak, Feb 24 2013
CROSSREFS
KEYWORD
nonn,easy,nice
AUTHOR
Miklos SZABO (mike(AT)ludens.elte.hu)
STATUS
approved