login
Length of binary expansion (or number of bits) of the n-th squarefree number.
17

%I #11 Aug 03 2024 01:52:44

%S 1,2,2,3,3,3,4,4,4,4,4,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,

%T 6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,

%U 7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8

%N Length of binary expansion (or number of bits) of the n-th squarefree number.

%F a(n) = A070939(A005117(n)).

%F a(n) = A372472(n) + A372433(n).

%e The 10th squarefree number is 14, with binary expansion (1,1,1,0), so a(10) = 4.

%t IntegerLength[Select[Range[1000],SquareFreeQ],2]

%o (Python)

%o from math import isqrt

%o from sympy import mobius

%o def A372475(n):

%o def f(x): return n+x-sum(mobius(k)*(x//k**2) for k in range(1, isqrt(x)+1))

%o m, k = n, f(n)

%o while m != k:

%o m, k = k, f(k)

%o return int(m).bit_length() # _Chai Wah Wu_, Aug 02 2024

%Y For prime instead of squarefree we have A035100, 1's A014499, 0's A035103.

%Y Restriction of A070939 to A005117.

%Y Run-lengths are A077643.

%Y For weight instead of length we have A372433 (restrict A000120 to A005117).

%Y For zeros instead of length we have A372472, firsts A372473.

%Y Positions of first appearances are A372540.

%Y A030190 gives binary expansion, reversed A030308.

%Y A048793 lists positions of ones in reversed binary expansion, sum A029931.

%Y A371571 lists positions of zeros in binary expansion, sum A359359.

%Y A371572 lists positions of ones in binary expansion, sum A230877.

%Y A372515 lists positions of zeros in reversed binary expansion, sum A359400.

%Y Cf. A003714, A023416, A049093, A049094, A059015, A069010, A073642, A145037, A211997, A368494, A372474, A372516.

%K nonn,base

%O 1,2

%A _Gus Wiseman_, May 09 2024