cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A348363 The 1's in the binary expansion of a(n) encode the distances between the 1's in the binary expansion of n.

This page as a plain text file.
%I A348363 #17 Oct 18 2021 01:38:54
%S A348363 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,
%T A348363 31,15,31,1,33,17,51,9,45,27,63,5,45,21,63,15,47,31,63,3,51,27,59,15,
%U A348363 63,31,63,7,63,31,63,15,63,31,63,1,65,33,99,17,85,51
%N A348363 The 1's in the binary expansion of a(n) encode the distances between the 1's in the binary expansion of n.
%C A348363 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.
%C A348363 This sequence has similarities with A067398; here we take the absolute differences, there the sums, of indices of 1's in binary expansions.
%C A348363 All terms are odd, except a(0) = 0.
%H A348363 Rémy Sigrist, <a href="/A348363/b348363.txt">Table of n, a(n) for n = 0..8192</a>
%H A348363 Rémy Sigrist, <a href="/A348363/a348363.png">Colored scatterplot of the first 2^20 terms</a> (where the color is function of the 2-adic valuation of n, upper red pixels correspond to odd n's)
%H A348363 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F A348363 a(2*n) = a(n).
%F A348363 a(n) = n iff n = 0 or n belongs to A064896.
%F A348363 a(n) = 1 iff n is a power of 2 (A000079).
%F A348363 a(n) = 3 iff n belongs to A007283.
%F A348363 a(n) = 5 iff n belongs to A020714.
%F A348363 a(n) AND n = n for any odd number n (where AND denotes the bitwise AND operator).
%e A348363 The first terms, in decimal and in binary, are:
%e A348363   n   a(n)  bin(n)  bin(a(n))
%e A348363   --  ----  ------  ---------
%e A348363    0     0       0          0
%e A348363    1     1       1          1
%e A348363    2     1      10          1
%e A348363    3     3      11         11
%e A348363    4     1     100          1
%e A348363    5     5     101        101
%e A348363    6     3     110         11
%e A348363    7     7     111        111
%e A348363    8     1    1000          1
%e A348363    9     9    1001       1001
%e A348363   10     5    1010        101
%e A348363   11    15    1011       1111
%e A348363   12     3    1100         11
%e A348363   13    15    1101       1111
%e A348363   14     7    1110        111
%e A348363   15    15    1111       1111
%t A348363 {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 *)
%o A348363 (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]) }
%o A348363 (Python)
%o A348363 def a(n):
%o A348363     locs = [e for e in range(n.bit_length()) if 1 & (n>>e)]
%o A348363     diffs = set(abs(e1-e2) for i, e1 in enumerate(locs) for e2 in locs[i:])
%o A348363     return sum(2**d for d in diffs)
%o A348363 print([a(n) for n in range(71)]) # _Michael S. Branicky_, Oct 16 2021
%Y A348363 Cf. A000079, A007283, A020714, A064896, A067398.
%K A348363 nonn,base
%O A348363 0,4
%A A348363 _Rémy Sigrist_, Oct 15 2021