OFFSET
0,4
LINKS
Indranil Ghosh, Table of n, a(n) for n = 0..10000
FORMULA
EXAMPLE
For n=10, the LCM of all the numbers from 1 to 10 is 2520 = 100111011000_2, which has a total of 6 1's, so a(10)=6.
MATHEMATICA
Map[DigitCount[#, 2, 1] &, FoldList[LCM, 1, Range@ 50]] (* Michael De Vlieger, Dec 13 2016 *)
PROG
(Python)
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd(a, b)
def c(*ar):
return reduce(lcm, ar)
def a(n):
if n==0:
return 1
x=bin(c(*range(1, n+1)))[2:]
return x.count("1")
for i in range(0, 10001):
print str(i)+" "+str(a(i))
(PARI) a(n) = hammingweight(lcm(vector(n, k, k))); \\ Michel Marcus, Dec 14 2016
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Indranil Ghosh, Dec 13 2016
STATUS
approved