OFFSET
0,2
LINKS
Chai Wah Wu, Table of n, a(n) for n = 0..56
Wikipedia, Hamming weight.
EXAMPLE
The squarefree numbers A005117(a(n)) together with their binary expansions and binary indices begin:
1: 1 ~ {1}
3: 11 ~ {1,2}
7: 111 ~ {1,2,3}
15: 1111 ~ {1,2,3,4}
31: 11111 ~ {1,2,3,4,5}
95: 1011111 ~ {1,2,3,4,5,7}
127: 1111111 ~ {1,2,3,4,5,6,7}
255: 11111111 ~ {1,2,3,4,5,6,7,8}
511: 111111111 ~ {1,2,3,4,5,6,7,8,9}
1023: 1111111111 ~ {1,2,3,4,5,6,7,8,9,10}
2047: 11111111111 ~ {1,2,3,4,5,6,7,8,9,10,11}
6143: 1011111111111 ~ {1,2,3,4,5,6,7,8,9,10,11,13}
8191: 1111111111111 ~ {1,2,3,4,5,6,7,8,9,10,11,12,13}
16383: 11111111111111 ~ {1,2,3,4,5,6,7,8,9,10,11,12,13,14}
32767: 111111111111111 ~ {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
65535: 1111111111111111 ~ {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}
131071: 11111111111111111 ~ {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}
MATHEMATICA
nn=10000;
spnm[y_]:=Max@@NestWhile[Most, y, Union[#]!=Range[0, Max@@#]&];
dcs=DigitCount[Select[Range[nn], SquareFreeQ], 2, 1];
Table[Position[dcs, i][[1, 1]], {i, spnm[dcs-1]}]
PROG
(Python)
from math import isqrt
from itertools import count
from sympy import factorint, mobius
from sympy.utilities.iterables import multiset_permutations
def A372541(n):
if n==0: return 1
for l in count(n):
m = 1<<l
for d in multiset_permutations('0'*(l-n)+'1'*n):
k = m+int('0'+''.join(d), 2)
if max(factorint(k).values(), default=0)==1:
return sum(mobius(a)*(k//a**2) for a in range(1, isqrt(k)+1)) # Chai Wah Wu, May 10 2024
KEYWORD
nonn,base
AUTHOR
Gus Wiseman, May 09 2024
EXTENSIONS
a(23)-a(33) from Chai Wah Wu, May 10 2024
STATUS
approved