login
A344602
Integers whose Hamming weight is triangular.
3
0, 1, 2, 4, 7, 8, 11, 13, 14, 16, 19, 21, 22, 25, 26, 28, 32, 35, 37, 38, 41, 42, 44, 49, 50, 52, 56, 63, 64, 67, 69, 70, 73, 74, 76, 81, 82, 84, 88, 95, 97, 98, 100, 104, 111, 112, 119, 123, 125, 126, 128, 131, 133, 134, 137, 138, 140, 145, 146, 148, 152, 159, 161
OFFSET
1,3
LINKS
MAPLE
q:= n-> issqr(8*add(i, i=Bits[Split](n))+1):
select(q, [$0..200])[]; # Alois P. Heinz, May 24 2021
MATHEMATICA
Select[Range[0, 200], IntegerQ @ Sqrt[8 * Plus @@ IntegerDigits[#, 2] + 1] &] (* Amiram Eldar, May 24 2021 *)
PROG
(PARI) isok(n) = ispolygonal(hammingweight(n), 3);
(Python)
from math import isqrt, comb
from sympy.ntheory.primetest import is_square
from oeis_sequences.OEISsequences import bisection
def A344602(n):
def f(x):
s = bin(x)[-1:1:-1]
m = x.bit_count()
l = x.bit_length()
l2 = (k:=isqrt(t:=l+1<<1))+int((t<<2)>(k<<2)*(k+1)+1)
a = is_square((m<<3)|1)
c = n+x-a
for i in range(l):
j = int(s[i])
if j:
m -= 1
r = (k:=isqrt(t:=m+1<<1))+int((t<<2)>(k<<2)*(k+1)+1)-1
for p in range(r+(not is_square((m<<3)|1)), l2):
c -= comb(i, comb(p+1, 2)-m)
return c
return bisection(f, n-1, n-1) # Chai Wah Wu, Jun 09 2026
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Michel Marcus, May 24 2021
STATUS
approved