login
a(n) is the length of the longest contiguous block of ones in the binary expansion of 1/n.
2

%I #7 Mar 11 2018 17:17:31

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

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

%U 3,3,3,3,3,5,3,4,4,2,4,2,6,5,6,2,2,5,4

%N a(n) is the length of the longest contiguous block of ones in the binary expansion of 1/n.

%C This sequence has similarities with A038374: here we consider the binary expansion of 1/n, there the binary expansion of n.

%F a(2*n) = a(n).

%F a(2^k + 1) = k for any k > 0.

%F a(n) = 1 iff n belongs to A300630.

%e The first terms, alongside the binary representation of 1/n, are:

%e n a(n) bin(1/n) with repeating digits in parentheses

%e -- ---- ---------------------------------------------

%e 1 1 1.(0)

%e 2 1 0.1(0)

%e 3 1 0.(01)

%e 4 1 0.01(0)

%e 5 2 0.(0011)

%e 6 1 0.0(01)

%e 7 1 0.(001)

%e 8 1 0.001(0)

%e 9 3 0.(000111)

%e 10 2 0.0(0011)

%e 11 3 0.(0001011101)

%e 12 1 0.00(01)

%e 13 3 0.(000100111011)

%e 14 1 0.0(001)

%e 15 1 0.(0001)

%e 16 1 0.0001(0)

%e 17 4 0.(00001111)

%e 18 3 0.0(000111)

%e 19 4 0.(000011010111100101)

%e 20 2 0.00(0011)

%o (PARI) a(n) = my (w=1, s=Set(), f=1/max(n,2)); while (!setsearch(s,f), while (floor(f*2^(w+1))==2^(w+1)-1, w++); s=setunion(s,Set(f)); f=frac(f*2)); return (w)

%Y Cf. A038374, A300630.

%K nonn,base

%O 1,5

%A _Rémy Sigrist_, Mar 10 2018