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.

A303548 For any n > 0 and h > 0, let d_h(n) be the distance from n to the nearest number with Hamming weight at most h; a(n) = Sum_{i > 0} d_i(n).

This page as a plain text file.
%I A303548 #23 Apr 28 2018 19:54:20
%S A303548 0,0,1,0,1,2,2,0,1,2,4,4,4,4,3,0,1,2,4,4,6,8,9,8,8,8,9,8,7,6,4,0,1,2,
%T A303548 4,4,6,8,9,8,10,12,15,16,17,18,18,16,16,16,17,16,17,18,18,16,15,14,14,
%U A303548 12,10,8,5,0,1,2,4,4,6,8,9,8,10,12,15,16,17,18
%N A303548 For any n > 0 and h > 0, let d_h(n) be the distance from n to the nearest number with Hamming weight at most h; a(n) = Sum_{i > 0} d_i(n).
%C A303548 For any n > 0 and h >= A000120(n), d_h(n) = 0, hence the series in the name contains only finitely many nonzero terms and is well defined.
%C A303548 See also A303545 for a similar sequence.
%H A303548 Rémy Sigrist, <a href="/A303548/b303548.txt">Table of n, a(n) for n = 1..10000</a>
%H A303548 Rémy Sigrist, <a href="/A303548/a303548.png">Colored pin plot of the first 3 * 512 terms</a> (where the color is function of the number h in the term d_h(n))
%H A303548 <a href="/index/Di#distance_to_the_nearest">Index entries for sequences related to distance to nearest element of some set</a>
%F A303548 a(n) = 0 iff n is a power of 2.
%F A303548 Apparently, a(2 * n) = 2 * a(n).
%F A303548 a(n) >= A053646(n) (as d_1 = A053646).
%e A303548 For n = 42:
%e A303548 - d_1(n) = |42 - 32| = 10,
%e A303548 - d_2(n) = |42 - 40| = 2,
%e A303548 - d_h(n) = 0 for any h >= 3,
%e A303548 - hence a(42) = 10 + 2 = 12.
%o A303548 (PARI) a(n) = my (v=0, h=hamming weight(n)); for (d=0, oo, my (o=min(hamming weight(n-d), hamming weight(n+d))); if (o<h, v += d*(h-o); h=o); if (o<=1, return (v)))
%Y A303548 Cf. A000120, A053646, A303545.
%K A303548 nonn,base,look
%O A303548 1,6
%A A303548 _Rémy Sigrist_, Apr 26 2018