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.

A231897 a(n) = smallest m such that wt(m^2) = n (where wt(i) = A000120(i)), or -1 if no such m exists.

This page as a plain text file.
%I A231897 #33 Jul 23 2025 07:55:21
%S A231897 0,1,3,5,13,11,21,39,45,75,155,217,331,181,627,923,1241,2505,3915,
%T A231897 5221,6475,11309,15595,19637,31595,44491,69451,113447,185269,244661,
%U A231897 357081,453677,1015143,908091,980853,2960011,4568757,2965685,5931189,11862197,20437147
%N A231897 a(n) = smallest m such that wt(m^2) = n (where wt(i) = A000120(i)), or -1 if no such m exists.
%C A231897 Conjecture: a(n) is never -1. (It seems likely that the arguments of Lindström (1997) could be modified to establish this conjecture.)
%C A231897 a(n) is the smallest m such that A159918(m) = n (or -1 if ...).
%H A231897 Hugo Pfoertner, <a href="/A231897/b231897.txt">Table of n, a(n) for n = 0..110</a> (terms 0..70 from Donovan Johnson, significant extension enabled by programs provided in Code Golf challenge).
%H A231897 Code Golf Stackexchange, <a href="https://codegolf.stackexchange.com/questions/255529/smallest-and-largest-100-bit-square-with-maximum-hamming-weight">Smallest and largest 100-bit square with maximum Hamming weight</a>, fastest code challenge started Dec 15 2022.
%H A231897 Bernt Lindström, <a href="http://dx.doi.org/10.1006/jnth.1997.2129">On the binary digits of a power</a>, Journal of Number Theory, Volume 65, Issue 2, August 1997, Pages 321-324.
%F A231897 a(n) = 2*A211201(n-1) + 1 for n >= 1. - _Hugo Pfoertner_, Feb 06 2022
%o A231897 (Haskell)
%o A231897 a231897 n = head [x | x <- [1..], a159918 x == n]
%o A231897 -- _Reinhard Zumkeller_, Nov 20 2013
%o A231897 (PARI) a(n)=if(n,my(k); while(hammingweight(k++^2)!=n,); k, 0) \\ _Charles R Greathouse IV_, Aug 06 2015
%o A231897 (Python)
%o A231897 def wt(n): return bin(n).count('1')
%o A231897 def a(n):
%o A231897     m = 2**(n//2) - 1
%o A231897     while wt(m**2) != n: m += 1
%o A231897     return m
%o A231897 print([a(n) for n in range(32)]) # _Michael S. Branicky_, Feb 06 2022
%Y A231897 Cf. A000120, A159918, A230097, A211201, A231898, A214560.
%Y A231897 A089998 are the corresponding squares.
%K A231897 nonn,base
%O A231897 0,3
%A A231897 _N. J. A. Sloane_, Nov 19 2013
%E A231897 a(26)-a(40) from _Reinhard Zumkeller_, Nov 20 2013