A188666 Largest m <= n such that lcm(m, m+1, ..., n) = lcm(1, 2, ..., n).
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, 16, 16, 16, 17, 17, 19, 19, 19, 19, 23, 23, 23, 23, 23, 23, 23, 23, 25, 25, 25, 25, 27, 27, 27, 27, 29, 29, 29, 29, 31, 31, 31, 31, 32, 32, 37, 37, 37, 37, 37, 37
Offset: 1
Keywords
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
- Eric Weisstein's World of Mathematics, Least Common Multiple
- Wikipedia, Least Common Multiple
- Index entries for sequences related to lcm's
Programs
-
Haskell
import Data.List (elemIndices) a188666 n = a188666_list !! (n-1) a188666_list = g 1 a000961_list where g n pps'@(pp:pp':pps) | n < 2*pp = pp : g (n+1) pps' | otherwise = pp' : g (n+1) (pp':pps) -- Alternative, rewriting the definition, but less efficient: a188666' n = last $ elemIndices (f 1) $ map f [0..n] where f from = foldl lcm 1 [from..n]
-
Mathematica
Table[Block[{k = n, m = LCM @@ Range[n]}, While[LCM @@ Range[k, n] != m, k--]; k], {n, 69}] (* Michael De Vlieger, Nov 29 2022 *)
-
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
-
Python
from itertools import count from sympy import factorint def A188666(n): return next(filter(lambda m:len(factorint(m))<=1, count((n>>1)+1))) # Chai Wah Wu, Oct 25 2024
Comments