A099244 Greatest common divisor of length of n in binary representation and its number of ones.
1, 1, 2, 1, 1, 1, 3, 1, 2, 2, 1, 2, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 2, 3, 2, 2, 1, 2, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
Offset: 1
Links
Programs
-
Haskell
a099244 n = gcd (a070939 n) (a000120 n) -- Reinhard Zumkeller, Oct 10 2013
-
Mathematica
a[n_] := GCD[BitLength[n], DigitCount[n, 2, 1]]; Array[a, 100] (* Amiram Eldar, Jul 16 2023 *)
-
PARI
a(n) = {my(b = binary(n)); gcd(#b, vecsum(b));} \\ Amiram Eldar, Jul 26 2025
-
Python
from math import gcd def a(n): b = bin(n)[2:]; return gcd(len(b), b.count('1')) print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Jun 17 2021
Comments