|
|
A348363
|
|
The 1's in the binary expansion of a(n) encode the distances between the 1's in the binary expansion of n.
|
|
1
|
|
|
0, 1, 1, 3, 1, 5, 3, 7, 1, 9, 5, 15, 3, 15, 7, 15, 1, 17, 9, 27, 5, 21, 15, 31, 3, 27, 15, 31, 7, 31, 15, 31, 1, 33, 17, 51, 9, 45, 27, 63, 5, 45, 21, 63, 15, 47, 31, 63, 3, 51, 27, 59, 15, 63, 31, 63, 7, 63, 31, 63, 15, 63, 31, 63, 1, 65, 33, 99, 17, 85, 51
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,4
|
|
COMMENTS
|
The bit 2^d is set in a(n) iff for some e >= 0, the bits 2^e and 2^(e+d) are set in n.
This sequence has similarities with A067398; here we take the absolute differences, there the sums, of indices of 1's in binary expansions.
All terms are odd, except a(0) = 0.
|
|
LINKS
|
|
|
FORMULA
|
a(2*n) = a(n).
a(n) = n iff n = 0 or n belongs to A064896.
a(n) = 1 iff n is a power of 2 (A000079).
a(n) AND n = n for any odd number n (where AND denotes the bitwise AND operator).
|
|
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 1 10 1
3 3 11 11
4 1 100 1
5 5 101 101
6 3 110 11
7 7 111 111
8 1 1000 1
9 9 1001 1001
10 5 1010 101
11 15 1011 1111
12 3 1100 11
13 15 1101 1111
14 7 1110 111
15 15 1111 1111
|
|
MATHEMATICA
|
{0}~Join~Array[Total[2^Append[Union@ Abs[Subtract @@@ Permutations[1 + Length[#] - Position[#, 1][[All, 1]] &@ IntegerDigits[#, 2], {2}]], 0]] &, 70] (* Michael De Vlieger, Oct 16 2021 *)
|
|
PROG
|
(PARI) a(n) = { my (b=vector(hammingweight(n))); for (k=1, #b, n-=2^b[k]=valuation(n, 2); ); my (p=setbinop((i, j)->abs(i-j), b)); sum (k=1, #p, 2^p[k]) }
(Python)
def a(n):
locs = [e for e in range(n.bit_length()) if 1 & (n>>e)]
diffs = set(abs(e1-e2) for i, e1 in enumerate(locs) for e2 in locs[i:])
return sum(2**d for d in diffs)
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|