OFFSET
0,4
COMMENTS
a(0) = 0 as the GCD of an empty list (we consider here that the binary expansion of 0 has no runs).
LINKS
FORMULA
a(A001196(n)) = 2*a(n).
a(2^k-1) = k for any k >= 0.
MATHEMATICA
{0}~Join~Array[GCD @@ Map[Length, Split@ IntegerDigits[#, 2]] &, 104] (* Michael De Vlieger, Oct 17 2022 *)
PROG
(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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Oct 15 2022
STATUS
approved