OFFSET
1,2
LINKS
FORMULA
EXAMPLE
A067576(12) = 9, so a(9) = 12.
PROG
(PARI) a(n)=my(w=hammingweight(n), p=sum(i=1, n-1, hammingweight(i)==w)); binomial(w+p+1, 2) - p
(Python)
from math import comb
def A356419(n):
c, k = 0, 0
for i, j in enumerate(bin(n)[-1:1:-1]):
if j == '1':
k += 1
c += comb(i, k)
return comb(n.bit_count()+c+1, 2)-c # Chai Wah Wu, Mar 02 2023
CROSSREFS
KEYWORD
AUTHOR
Jianing Song, Aug 06 2022
STATUS
approved