login
A343049
The k-th binary digit of a(n) is the most frequent digit among the first k binary digits of n (in case of a tie, take the k-th binary digit of n).
2
0, 1, 2, 7, 0, 5, 6, 31, 0, 9, 10, 31, 8, 29, 30, 127, 0, 1, 2, 23, 0, 21, 22, 127, 0, 25, 26, 127, 24, 125, 126, 511, 0, 1, 2, 39, 0, 37, 38, 127, 0, 41, 42, 127, 40, 125, 126, 511, 0, 33, 34, 119, 32, 117, 118, 511, 32, 121, 122, 511, 120, 509, 510, 2047, 0
OFFSET
0,3
COMMENTS
Leading zeros are taken into account up to the point the number of zeros exceeds the total number of ones.
We scan the binary representation of a number starting from the least significant digit. See A343271 for the other way.
FORMULA
a(n) = 0 iff n belongs to A036993.
a(n) = n iff n = 0 or n belongs to A032925.
a(2^k-1) = 2^(2*k-1)-1 for any k > 1.
A070939(a(n)) < 2*A070939(n).
EXAMPLE
The first terms, in decimal and in binary, are:
n a(n) bin(n) bin(a(n))
-- ---- ------ ---------
0 0 0 0
1 1 1 1
2 2 10 10
3 7 11 111
4 0 100 0
5 5 101 101
6 6 110 110
7 31 111 11111
8 0 1000 0
9 9 1001 1001
10 10 1010 1010
11 31 1011 11111
12 8 1100 1000
13 29 1101 11101
14 30 1110 11110
15 127 1111 1111111
PROG
(PARI) a(n, base=2) = { my (d=digits(n, base), t, f=vector(base)); d=concat(vector(#d), d); forstep (k=#d, 1, -1, f[1+d[k]]++; if (vecmax(f)==f[1+d[k]], t=d[k]; ); d[k]=t); fromdigits(d, base) }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Apr 09 2021
STATUS
approved