A070972 Length of longest run of consecutive 1's in binary expansion of 3^n (A004656).
1, 2, 1, 2, 1, 4, 2, 2, 2, 3, 3, 7, 6, 4, 5, 4, 3, 4, 4, 4, 6, 5, 5, 4, 3, 2, 10, 8, 7, 5, 4, 5, 7, 9, 8, 6, 5, 7, 11, 10, 8, 6, 6, 4, 9, 7, 6, 4, 9, 8, 6, 9, 8, 6, 5, 5, 3, 4, 7, 5, 10, 8, 7, 6, 6, 6, 6, 4, 4, 7, 7, 5, 5, 5, 5, 5, 5, 9, 8, 6, 5, 6, 5, 6, 5, 5, 4, 6, 5, 10, 8, 7, 5, 6, 6, 6, 7, 7, 6, 7, 5, 5, 5, 9
Offset: 0
Examples
3^11 = (101011001111111011) binary, so a(11) = 7.
Programs
-
Mathematica
f[n_Integer] := Block[{p = Flatten[ Position[ Prepend[ IntegerDigits[2*3^n, 2], 0], 0]]}, Max[Drop[p, 1] - Drop[p, -1]] - 1]; Table[ f[n], {n, 0, 103}]
Extensions
Edited by Robert G. Wilson v, Jan 04 2002
Comments