A300655 a(n) is the length of the longest contiguous block of ones in the binary expansion of 1/n.
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, 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, 3, 3, 3, 3, 3, 5, 3, 4, 4, 2, 4, 2, 6, 5, 6, 2, 2, 5, 4
Offset: 1
Examples
The first terms, alongside the binary representation of 1/n, are: n a(n) bin(1/n) with repeating digits in parentheses -- ---- --------------------------------------------- 1 1 1.(0) 2 1 0.1(0) 3 1 0.(01) 4 1 0.01(0) 5 2 0.(0011) 6 1 0.0(01) 7 1 0.(001) 8 1 0.001(0) 9 3 0.(000111) 10 2 0.0(0011) 11 3 0.(0001011101) 12 1 0.00(01) 13 3 0.(000100111011) 14 1 0.0(001) 15 1 0.(0001) 16 1 0.0001(0) 17 4 0.(00001111) 18 3 0.0(000111) 19 4 0.(000011010111100101) 20 2 0.00(0011)
Programs
-
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)
Comments