|
|
A263017
|
|
n is the a(n)-th positive integer having its binary weight.
|
|
11
|
|
|
1, 2, 1, 3, 2, 3, 1, 4, 4, 5, 2, 6, 3, 4, 1, 5, 7, 8, 5, 9, 6, 7, 2, 10, 8, 9, 3, 10, 4, 5, 1, 6, 11, 12, 11, 13, 12, 13, 6, 14, 14, 15, 7, 16, 8, 9, 2, 15, 17, 18, 10, 19, 11, 12, 3, 20, 13, 14, 4, 15, 5, 6, 1, 7, 16, 17, 21, 18, 22, 23, 16, 19, 24, 25, 17
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
COMMENTS
|
a(2^k) = k+1 for any k>=0.
a(2^k-1) = 1 for any k>0.
a(A057168(k)) = a(k)+1 for any k>0.
|
|
LINKS
|
|
|
FORMULA
|
|
|
EXAMPLE
|
The numbers with binary weight 3 are: 7, 11, 13, 14, 19, ...
Hence: a(7)=1, a(11)=2, a(13)=3, a(14)=4, a(19)=5, ...
And more generally: a(A014311(k))=k for any k>0.
|
|
MAPLE
|
a:= proc() option remember; local a, b, t; b, a:=
proc() 0 end, proc(n) option remember; a(n-1);
t:= add(i, i=convert(n, base, 2)); b(t):= b(t)+1
end; a(0):=0; a
end():
|
|
PROG
|
(Perl) See Links section.
(Haskell)
import Data.IntMap (empty, findWithDefault, insert)
a263017 n = a263017_list !! (n-1)
a263017_list = f 1 empty where
f x m = y : f (x + 1) (insert h (y + 1) m) where
y = findWithDefault 1 h m
h = a000120 x
(Python)
def a(n):
x=bin(n)[2:].count("1")
return sum([1 for i in range(n) if bin(i)[2:].count("1")==x]) # Indranil Ghosh, May 24 2017
(Python)
from math import comb
c, k = 1, 0
for i, j in enumerate(bin(n)[-1:1:-1]):
if j == '1':
k += 1
c += comb(i, k)
|
|
CROSSREFS
|
|
|
KEYWORD
|
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|