login
A356352
a(n) = GCD of run lengths in binary expansion of n.
2
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,4
COMMENTS
a(0) = 0 as the GCD of an empty list (we consider here that the binary expansion of 0 has no runs).
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
Sequence in context: A257242 A337908 A325789 * A175597 A309400 A294306
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Oct 15 2022
STATUS
approved