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.

Showing 1-1 of 1 results.

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

Original entry on oeis.org

0, 23, 111, 479, 1471, 6015, 24319, 28415, 114175, 457727, 490495, 1964031, 6025215, 8122367, 32497663, 98549759, 132104191, 528449535, 1593769983, 1862205439, 7448952831, 25635323903, 29930291199, 119721689087, 411242070015, 479961546751, 514321285119, 2057287237631, 7687987265535
Offset: 0

Views

Author

Karl-Heinz Hofmann, Oct 10 2022

Keywords

Comments

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).
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).

Examples

			  -----------------------------------------------------------------------------
  n       k          k^2           binary k                          binary k^2
  -----------------------------------------------------------------------------
  0       0            0                  0                                   0
  1      23          529              10111                          1000010001
  2     111        12321            1101111                      11000000100001
  3     479       229441          111011111                  111000000001000001
  4    1471      2163841        10110111111              1000010000010010000001
  5    6015     36180225      1011101111111          10001010000001000100000001
  6   24319    591413761    101111011111111      100011010000000100001000000001
  7   28415    807412225    110111011111111      110000001000000010001000000001
  8  114175  13035930625  11011110111111111  1100001001000000001000010000000001
		

Crossrefs

Programs

  • Mathematica
    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 *)
  • PARI
    a(n) = my(k=0); while(hammingweight(k) - hammingweight(k^2) != n, k++); k; \\ Michel Marcus, Oct 14 2022
    
  • Python
    A356877 = [0]
    for n in range(1,29):
        s, k = -1, A356877[-1]
        while bin(A356877[-1])[s] == "1": s -= 1
        while bin(k)[2:].count("1")-bin(k**2)[2:].count("1") != n: k += 2**(abs(s)-1)
        A356877.append(k)
    print(A356877)
Showing 1-1 of 1 results.