A356352 a(n) = GCD of run lengths in binary expansion of n.
0, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 2, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
Offset: 0
Links
Programs
-
Mathematica
{0}~Join~Array[GCD @@ Map[Length, Split@ IntegerDigits[#, 2]] &, 104] (* Michael De Vlieger, Oct 17 2022 *)
-
PARI
a(n) = { my (r=[]); while (n, my (v=valuation(n+n%2, 2)); n\=2^v; r=concat(v, r)); gcd(r) }
-
Python
from math import gcd from itertools import groupby def a(n): if n == 0: return 0 # by convention return gcd(*(len(list(g)) for k, g in groupby(bin(n)[2:]))) print([a(n) for n in range(87)]) # Michael S. Branicky, Oct 15 2022
Formula
a(A001196(n)) = 2*a(n).
a(2^k-1) = k for any k >= 0.
Comments