login
A357660
a(n) is the largest k such that k^2 has a maximal Hamming weight A357658(n) in the range 2^n <= k^2 < 2^(n+1).
3
2, 3, 5, 7, 11, 15, 21, 27, 45, 53, 89, 117, 181, 235, 362, 491, 723, 949, 1241, 1773, 2891, 3915, 5747, 7093, 11309, 16203, 19637, 31595, 44491, 64747, 86581, 113447, 185269, 244661, 357081, 453677, 738539, 980853, 1481453, 2079669, 2965685, 3923411, 5931189, 8222581
OFFSET
2,1
LINKS
Hugo Pfoertner, Table of n, a(n) for n = 2..125, including results from Bert Dobbelaere and from users l4m2, gsitcia, and 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.
EXAMPLE
See A357658.
PROG
(Python 3.10+)
from math import isqrt
def A357660(n):
c = 0
for k in range(isqrt((1<<n)-1)+1, isqrt((1<<n+1)-1)+1):
if (d:=(k**2).bit_count()) > c:
c, m = d, k
elif d == c:
m = max(m, k)
return m # Chai Wah Wu, Oct 14 2022
(C, x64asm, Rust, c++) see Code Golf link.
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Hugo Pfoertner, Oct 09 2022
STATUS
approved