OFFSET
2,2
COMMENTS
The sequence can be approximated by a linear function c*n + d, with c ~= 0.883 +- 0.003, d ~= -1.65 +- 0.16. See linked plot. For a square number with 100 binary digits (n=99) a maximum Hamming weight of 85 or 86 is expected. For example, 1125891114428899^2 has Hamming weight 85.
LINKS
Hugo Pfoertner, Table of n, a(n) for n = 2..125, including results from Bert Dobbelaere and users l4m2, gsitcia, anttiP in Code Golf challenge (terms 103..125)
Code Golf Stackexchange, Smallest and largest 100-bit square with maximum Hamming weight, fastest code challenge started Dec 15 2022.
Hugo Pfoertner, Maximum of bits=1 in squares 2^n < k^2 < 2^(n+1), plot of linear fit (December 2022).
FORMULA
a(n) = n+1-A352631(n+1). - Pontus von Brömssen, Feb 23 2026
EXAMPLE
PROG
(Python)
from math import isqrt
def A357658(n): return max((k**2).bit_count() for k in range(isqrt((1<<n)-1)+1, isqrt((1<<n+1)-1)+1)) # Chai Wah Wu, Oct 14 2022
(C) // C and x64asm. See Code Golf link (user l4m2).
(Rust) // See Code Golf link (user gsitcia).
(C++) // See Code Golf link (user anttiP).
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Hugo Pfoertner, Oct 09 2022
STATUS
approved
