A343271 From left to right: 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).
0, 1, 2, 3, 4, 5, 7, 7, 8, 9, 10, 11, 14, 15, 15, 15, 16, 16, 18, 19, 20, 21, 23, 23, 28, 29, 31, 31, 31, 31, 31, 31, 32, 32, 32, 33, 36, 37, 38, 39, 40, 41, 42, 43, 46, 47, 47, 47, 56, 57, 58, 59, 62, 63, 63, 63, 62, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64
Offset: 0
Examples
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 3 11 11 4 4 100 100 5 5 101 101 6 7 110 111 7 7 111 111 8 8 1000 1000 9 9 1001 1001 10 10 1010 1010 11 11 1011 1011 12 14 1100 1110 13 15 1101 1111 14 15 1110 1111 15 15 1111 1111
Links
Programs
-
PARI
a(n, base=2) = { my (d=digits(n, base), f=vector(base), t); for (k=1, #d, f[1+d[k]]++; if (f[1+d[k]]==vecmax(f), t=d[k], d[k]=t)); fromdigits(d, base) }
Comments