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.

A356877 a(n) is the least number k such that (the binary weight of k) - (the binary weight of k^2) = n.

This page as a plain text file.
%I A356877 #41 Oct 18 2022 01:43:03
%S A356877 0,23,111,479,1471,6015,24319,28415,114175,457727,490495,1964031,
%T A356877 6025215,8122367,32497663,98549759,132104191,528449535,1593769983,
%U A356877 1862205439,7448952831,25635323903,29930291199,119721689087,411242070015,479961546751,514321285119,2057287237631,7687987265535
%N A356877 a(n) is the least number k such that (the binary weight of k) - (the binary weight of k^2) = n.
%C A356877 Note that the terms of A260986 with n > 1 can all be found here. Terms here that are not in A260986 have the property not to be a record value of the ratio (binary weight k) / (binary weight k^2).
%C A356877 Observation: The difference of two neighboring terms is a multiple of 2^(number of the ones after the last zero in binary expression of the smaller term).
%H A356877 K. B. Stolarsky, <a href="http://dx.doi.org/10.1090/S0002-9939-1978-0495823-5">The binary digits of a power</a>, Proc. Amer. Math. Soc. 71 (1978), pp. 1-5.
%e A356877   -----------------------------------------------------------------------------
%e A356877   n       k          k^2           binary k                          binary k^2
%e A356877   -----------------------------------------------------------------------------
%e A356877   0       0            0                  0                                   0
%e A356877   1      23          529              10111                          1000010001
%e A356877   2     111        12321            1101111                      11000000100001
%e A356877   3     479       229441          111011111                  111000000001000001
%e A356877   4    1471      2163841        10110111111              1000010000010010000001
%e A356877   5    6015     36180225      1011101111111          10001010000001000100000001
%e A356877   6   24319    591413761    101111011111111      100011010000000100001000000001
%e A356877   7   28415    807412225    110111011111111      110000001000000010001000000001
%e A356877   8  114175  13035930625  11011110111111111  1100001001000000001000010000000001
%t A356877 a[0] = 0; a[n_] := a[n] = Module[{step = If[n == 1, 1, 2^Length[Split[IntegerDigits[a[n - 1], 2]][[-1]]]], k = a[n - 1]}, While[DigitCount[k, 2, 1] - DigitCount[k^2, 2, 1] != n, k += step]; k]; Array[a, 23, 0] (* _Amiram Eldar_, Oct 14 2022 *)
%o A356877 (PARI) a(n) = my(k=0); while(hammingweight(k) - hammingweight(k^2) != n, k++); k; \\ _Michel Marcus_, Oct 14 2022
%o A356877 (Python)
%o A356877 A356877 = [0]
%o A356877 for n in range(1,29):
%o A356877     s, k = -1, A356877[-1]
%o A356877     while bin(A356877[-1])[s] == "1": s -= 1
%o A356877     while bin(k)[2:].count("1")-bin(k**2)[2:].count("1") != n: k += 2**(abs(s)-1)
%o A356877     A356877.append(k)
%o A356877 print(A356877)
%Y A356877 Cf. A000120, A159918, A260986, A357750.
%K A356877 nonn,base
%O A356877 0,2
%A A356877 _Karl-Heinz Hofmann_, Oct 10 2022