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.

A292895 a(n) is the least positive k such that the Hamming weight of k equals the Hamming weight of k + n.

This page as a plain text file.
%I A292895 #43 Oct 02 2017 18:19:20
%S A292895 1,1,2,1,4,5,2,1,8,3,10,6,4,5,2,1,16,3,6,5,20,3,12,10,8,9,10,6,4,5,2,
%T A292895 1,32,3,6,5,12,3,10,9,40,11,6,5,24,3,20,18,16,7,18,17,20,12,12,10,8,9,
%U A292895 10,6,4,5,2,1,64,3,6,5,12,3,10,9,24,11,6,5,20,3,18,17,80,7,22,14,12,13,10,9,48
%N A292895 a(n) is the least positive k such that the Hamming weight of k equals the Hamming weight of k + n.
%C A292895 Inspired by A292849.
%C A292895 The Hamming weight of a number n is given by A000120(n).
%C A292895 Let b(n) be the smallest t such that a(t) = n. Initial values of b(n) are 0, 2, 9, 4, 5, 11, 49, 8, 25, 10, 41, 22, 85, 83, 225, 16, 51, 47, 177, 20, ... See the logarithmic line graph of first 10^3 terms of b(n) sequence in Links section.
%C A292895 Apparently, n = a(n) iff n belongs to A094958. - _Rémy Sigrist_, Oct 02 2017
%H A292895 Rémy Sigrist, <a href="/A292895/b292895.txt">Table of n, a(n) for n = 0..16384</a>
%H A292895 Altug Alkan, <a href="/A292895/a292895_1.png">A logarithmic scatterplot of a(n) for n <= 10^6</a>
%H A292895 Altug Alkan, <a href="/A292895/a292895_2.png">A logarithmic line graph of b(n) for n <= 10^3</a>
%F A292895 a(n) <= n for n >= 1.
%F A292895 a(2*n) = 2*a(n) for n >= 1.
%F A292895 a(2^m) = 2^m and a(5*2^m) = 5*2^m for m >= 0.
%F A292895 a(2^m - 1) = 1 for m >= 0.
%F A292895 a(2^m + 1) = 3 and a(2^m - 3) = 5 for m >= 3.
%F A292895 a(2^m + 3) = 5 for m >= 4.
%F A292895 a((2^m - 1)^2) = 2^m - 1 for m >= 1.
%F A292895 a(2^(m + 2) + 2^m - 1) = 2^m + 1 m >= 1.
%F A292895 a((2^m + 1)^2) = 7 for m >= 3.
%e A292895 a(49) = 7 since A000120(7) = A000120(7 + 49) and 7 is the least number with this property.
%p A292895 N:= 1000: # to get all terms before the first where n+a(n)>N
%p A292895 H:= Array(0..N, t -> convert(convert(t,base,2),`+`)):
%p A292895 f:= proc(n) local k;
%p A292895   for k from 1 to N-n do
%p A292895     if H[k]=H[k+n] then return k fi
%p A292895   od:
%p A292895 0
%p A292895 end proc:
%p A292895 R:= NULL:
%p A292895 for n from 0 do
%p A292895 v:= f(n);
%p A292895 if v = 0 then break fi;
%p A292895   R:= R, v;
%p A292895 od:
%p A292895 R; # _Robert Israel_, Sep 27 2017
%t A292895 h[n_] := First@ DigitCount[n, 2]; a[n_] := Block[{k=1}, While[h[k] != h[k + n], k++]; k]; Array[a, 90] (* _Giovanni Resta_, Sep 28 2017 *)
%o A292895 (PARI) a(n) = {my(k=1); while ((hammingweight(k)) != hammingweight(n+k), k++); k; }
%Y A292895 Cf. A000120, A094958, A292849.
%K A292895 nonn,base,easy,look
%O A292895 0,3
%A A292895 _Rémy Sigrist_ and _Altug Alkan_, Sep 26 2017