login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A099244
Greatest common divisor of length of n in binary representation and its number of ones.
6
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,3
COMMENTS
For k >= 2, n in the range [2^(k-1)..2^k - 2] have binary length k but fewer than k 1's, thus a(n) is a proper divisor of k, and if k is a prime then a(n) = 1. - Ctibor O. Zizka, Jun 19 2021
FORMULA
a(n) = gcd(A070939(n), A000120(n)).
a(A000225(n)) = n and a(m) < n for m < A000225(n).
MATHEMATICA
a[n_] := GCD[BitLength[n], DigitCount[n, 2, 1]]; Array[a, 100] (* Amiram Eldar, Jul 16 2023 *)
PROG
(Haskell)
a099244 n = gcd (a070939 n) (a000120 n)
-- Reinhard Zumkeller, Oct 10 2013
(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
KEYWORD
base,easy,nonn
AUTHOR
Reinhard Zumkeller, Oct 08 2004
STATUS
approved