A377414 a(n) is the largest term of A126684, say b, such that n AND b = b (where AND denotes the bitwise AND operator).
0, 1, 2, 2, 4, 5, 4, 5, 8, 8, 10, 10, 8, 8, 10, 10, 16, 17, 16, 17, 20, 21, 20, 21, 16, 17, 16, 17, 20, 21, 20, 21, 32, 32, 34, 34, 32, 32, 34, 34, 40, 40, 42, 42, 40, 40, 42, 42, 32, 32, 34, 34, 32, 32, 34, 34, 40, 40, 42, 42, 40, 40, 42, 42, 64, 65, 64, 65
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 2 11 10 4 4 100 100 5 5 101 101 6 4 110 100 7 5 111 101 8 8 1000 1000 9 8 1001 1000 10 10 1010 1010 11 10 1011 1010 12 8 1100 1000 13 8 1101 1000 14 10 1110 1010 15 10 1111 1010
Links
Crossrefs
Programs
-
PARI
a(n) = { my (v = 0, x = exponent(n), y); while (n, n -= 2^y = exponent(n); if (x%2 == y%2, v += 2^y;);); return (v); }
Comments