login
Number of 0's in the binary expansion of the least common multiple of the first n integers.
1

%I #14 Dec 23 2016 21:57:53

%S 0,0,1,1,2,2,2,5,6,6,6,9,9,7,7,7,8,12,12,16,16,16,16,19,19,14,14,19,

%T 19,25,25,25,26,26,26,26,26,25,25,25,25,33,33,32,32,32,32,29,29,32,32,

%U 32,32,35,35,35,35,35,35,46,46,45

%N Number of 0's in the binary expansion of the least common multiple of the first n integers.

%H Indranil Ghosh, <a href="/A279515/b279515.txt">Table of n, a(n) for n = 0..10000</a>

%e For n = 10, the LCM of all the numbers from 1 to 10 is 2520 = 100111011000_2, which has a total of 6 0's, so a(10) = 6.

%t Map[DigitCount[#, 2, 0] &, {1}~Join~Table[LCM @@ Range@ n, {n, 61}]] (* _Michael De Vlieger_, Dec 16 2016 *)

%o (Python)

%o def gcd(a, b):

%o while b:

%o a, b = b, a % b

%o return a

%o def lcm(a, b):

%o return a * b // gcd(a, b)

%o def c(*ar):

%o return reduce(lcm, ar)

%o def a(n):

%o if n==0:

%o return 0

%o x=bin(c(*range(1, n+1)))[2:]

%o return x.count("0")

%o for i in range(0, 10001):

%o print str(i)+" "+str(a(i))

%o (PARI) a(n) = my(lcmn = lcm(vector(n, k, k))); #binary(lcmn) - hammingweight(lcmn); \\ _Michel Marcus_, Dec 23 2016

%Y Cf. A003418, A279506.

%K nonn,base

%O 0,5

%A _Indranil Ghosh_, Dec 13 2016