%I #32 Oct 25 2024 14:36:18
%S 1,2,2,3,3,4,4,5,5,7,7,7,7,8,8,9,9,11,11,11,11,13,13,13,13,16,16,16,
%T 16,16,16,17,17,19,19,19,19,23,23,23,23,23,23,23,23,25,25,25,25,27,27,
%U 27,27,29,29,29,29,31,31,31,31,32,32,37,37,37,37,37,37
%N Largest m <= n such that lcm(m, m+1, ..., n) = lcm(1, 2, ..., n).
%C By definition: A003418(n) = lcm(a(n), a(n)+1, ... n)
%C and lcm(m, m+1, ... n) < A003418(n) for m > a(n);
%C all terms are prime powers, cf. A000961: A010055(a(n)) = 1;
%C a(A110654(n)) = A000015(n);
%C floor(n/2)+1 <= a(n) < a(2*(a(n));
%C A000961(n+1) = a(2*A000961(n)) = a(A138929(n)), cf. formula.
%C A237709 gives number of occurrences of n-th prime power. - _Reinhard Zumkeller_, Feb 12 2014
%C Conjecture: a(n) = A000015(floor(n/2)+1). - _Georg Fischer_, Nov 29 2022
%H Reinhard Zumkeller, <a href="/A188666/b188666.txt">Table of n, a(n) for n = 1..10000</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/LeastCommonMultiple.html">Least Common Multiple</a>
%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Least_common_multiple">Least Common Multiple</a>
%H <a href="/index/Lc#lcm">Index entries for sequences related to lcm's</a>
%F a(n) = A000961(k+1) for n: 2*A000961(k) <= n < 2*A000961(k+1), k > 0.
%t Table[Block[{k = n, m = LCM @@ Range[n]}, While[LCM @@ Range[k, n] != m, k--]; k], {n, 69}] (* _Michael De Vlieger_, Nov 29 2022 *)
%o (Haskell)
%o import Data.List (elemIndices)
%o a188666 n = a188666_list !! (n-1)
%o a188666_list = g 1 a000961_list where
%o g n pps'@(pp:pp':pps) | n < 2*pp = pp : g (n+1) pps'
%o | otherwise = pp' : g (n+1) (pp':pps)
%o -- Alternative, rewriting the definition, but less efficient:
%o a188666' n = last $ elemIndices (f 1) $ map f [0..n] where
%o f from = foldl lcm 1 [from..n]
%o (PARI) A188666(n)=L=lcm(n=vector(n-1,k,k+1));!for(m=1,#n,lcm(n[-m..-1])==L&&return(#n+2-m))\\ Rather illustrative than efficient. - _M. F. Hasler_, Jul 25 2015
%o (Python)
%o from itertools import count
%o from sympy import factorint
%o def A188666(n): return next(filter(lambda m:len(factorint(m))<=1, count((n>>1)+1))) # _Chai Wah Wu_, Oct 25 2024
%Y Cf. A000015, A051173, A099996.
%K nonn,changed
%O 1,2
%A _Reinhard Zumkeller_, Apr 25 2011