%I #81 Apr 15 2024 13:10:29
%S 1,1,2,6,24,120,20,140,1120,10080,1008,11088,924,12012,858,12870,
%T 205920,3500640,194480,3695120,184756,3879876,176358,4056234,97349616,
%U 2433740400,93605400,2527345800,90262350,2617608150,87253605,2704861755,86555576160,2856334013280
%N a(n+1) = a(n)/n if n|a(n) else a(n)*n, a(1) = 1.
%C The graph of log_10(a(n)+1) seems to suggest that log(a(n)) is asymptotic to C*n where C is approximately 0.8. - _Daniel Forgues_, Sep 18 2011
%C Comments from _N. J. A. Sloane_, Apr 14 2024: (Start)
%C See A370968 for the terms in increasing order with duplicates omitted.
%C See A337486 and A195504 for the n such that a(n+1) = a(n)/n.
%C Guy and Nowakowski give bounds on a(n).
%C Theorem: 1 is the only repeated term.
%C Proof: Write a(n) for A008336(n).
%C Suppose, seeking a contradiction, that for 1 < r < s we have a(r) = a(s).
%C This means that a(r)*r^e_0*(r+1)^e_1*(r+2)^e_2*...(s-1)^e_t = a(s) = a(r),
%C where the exponents e_* are +1 or -1. The product (P1, say) of the terms with exponent +1 must equal the product (P2, say) of the terms with exponent -1. Since r>1, we need s >= r+2.
%C The product P1*P2 = P1^2 of all these terms is (s-1)!/(r-1)!.
%C But this contradicts Erdos's theorem (Erdos 1939) that the product of two or more consecutive integers is never a square. QED.
%C (End)
%D P. Erdos, On the product of consecutive integers, J. London Math. Soc., 14 (1939), 194-198.
%H Indranil Ghosh, <a href="/A008336/b008336.txt">Table of n, a(n) for n = 1..2732</a> (terms 1..1000 from T. D. Noe)
%H R. K. Guy and R. Nowakowski, <a href="http://www.jstor.org/stable/2975272">Unsolved Problems</a>, Amer. Math. Monthly, vol. 102 (1995), 921-926; circa page 924.
%H R. K. Guy and R. Nowakowski, <a href="/A008336/a008336.jpg">Annotated extract from previous link</a>
%H Nick Hobson, <a href="/A008336/a008336.py.txt">Python program for this sequence</a>
%H N. J. A. Sloane, <a href="http://neilsloane.com/doc/sg.txt">My favorite integer sequences</a>, in Sequences and their Applications (Proceedings of SETA '98).
%H <a href="/index/Rea#Recaman">Index entries for sequences related to Recamán's sequence</a>
%p 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;
%t 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 *)
%t 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 *)
%o (Haskell)
%o a008336 n = a008336_list !! (n-1)
%o a008336_list = 1 : zipWith (/*) a008336_list [1..] where
%o x /* y = if x `mod` y == 0 then x `div` y else x*y
%o -- _Reinhard Zumkeller_, Feb 22 2012, Oct 25 2010
%o (Python)
%o from functools import lru_cache
%o @lru_cache(maxsize=None)
%o def A008336(n):
%o if n == 1: return 1
%o a, b = divmod(c:=A008336(n-1),n-1)
%o return c*(n-1) if b else a # _Chai Wah Wu_, Apr 11 2024
%Y Cf. A005132 (the original Recaman sequence).
%Y A065422 and A260850 are variants of the present sequence.
%Y Cf. also A195504 = Product of numbers up to n-1 used as divisors in A008336(n), n >= 2; a(1) = 1.
%Y Cf. also A337486, A370968.
%K nonn,easy,nice,look
%O 1,3
%A _Bernardo Recamán_