A008336 a(n+1) = a(n)/n if n|a(n) else a(n)*n, a(1) = 1.
1, 1, 2, 6, 24, 120, 20, 140, 1120, 10080, 1008, 11088, 924, 12012, 858, 12870, 205920, 3500640, 194480, 3695120, 184756, 3879876, 176358, 4056234, 97349616, 2433740400, 93605400, 2527345800, 90262350, 2617608150, 87253605, 2704861755, 86555576160, 2856334013280
Offset: 1
References
- P. Erdos, On the product of consecutive integers, J. London Math. Soc., 14 (1939), 194-198.
Links
- Indranil Ghosh, Table of n, a(n) for n = 1..2732 (terms 1..1000 from T. D. Noe)
- R. K. Guy and R. Nowakowski, Unsolved Problems, Amer. Math. Monthly, vol. 102 (1995), 921-926; circa page 924.
- R. K. Guy and R. Nowakowski, Annotated extract from previous link
- Nick Hobson, Python program for this sequence
- N. J. A. Sloane, My favorite integer sequences, in Sequences and their Applications (Proceedings of SETA '98).
- Index entries for sequences related to Recamán's sequence
Crossrefs
Programs
-
Haskell
a008336 n = a008336_list !! (n-1) a008336_list = 1 : zipWith (/*) a008336_list [1..] where x /* y = if x `mod` y == 0 then x `div` y else x*y -- Reinhard Zumkeller, Feb 22 2012, Oct 25 2010
-
Maple
A008336 := proc(n) option remember; if n = 1 then 1 elif A008336(n-1) mod (n-1) = 0 then A008336(n-1)/(n-1) else A008336(n-1)*(n-1); fi; end;
-
Mathematica
a[n_] := a[n] = If[ Divisible[ a[n-1], n-1], a[n-1]/(n-1), a[n-1]*(n-1)]; a[1] = 1; Table[a[n], {n, 1, 28}] (* Jean-François Alcover, Dec 02 2011 *) nxt[{n_,a_}]:={n+1,If[Divisible[a,n],a/n,n*a]}; Transpose[ NestList[ nxt,{1,1},30]][[2]] (* Harvey P. Dale, May 09 2016 *)
-
Python
from functools import lru_cache @lru_cache(maxsize=None) def A008336(n): if n == 1: return 1 a, b = divmod(c:=A008336(n-1),n-1) return c*(n-1) if b else a # Chai Wah Wu, Apr 11 2024
Comments