A361477 a(n) is the number of integers whose binary expansions have the same multiset of run-lengths as that of n.
1, 1, 1, 1, 2, 1, 2, 1, 2, 3, 1, 3, 1, 3, 2, 1, 2, 3, 4, 3, 4, 1, 4, 3, 2, 3, 4, 3, 2, 3, 2, 1, 2, 3, 4, 6, 6, 5, 6, 6, 4, 5, 1, 5, 6, 5, 4, 3, 2, 6, 6, 1, 6, 5, 6, 6, 1, 6, 4, 6, 2, 3, 2, 1, 2, 3, 4, 6, 12, 5, 12, 3, 12, 10, 6, 10, 4, 10, 12, 6, 4, 5, 6, 10
Offset: 0
Examples
For n = 18: - the binary expansion of 18 is "10010", - the corresponding multiset of run-lengths is m = (1, 2, 1, 1), - m has 4 terms: 3 times "1" and once "2", - so a(18) = 4! / (3! * 1!) = 4.
Links
Programs
-
PARI
a(n) = { my (r=[]); while (n, my (v=valuation(n+n%2, 2)); n\=2^v; r=concat(v, r)); my (s=Set(r), f=vector(#s)); for (k=1, #r, f[setsearch(s, r[k])]++); (#r)! / prod(k=1, #f, f[k]!) }
-
Python
from math import factorial, prod from itertools import groupby from collections import Counter def A361477(n): return factorial(len(c:=[len(list(g)) for k, g in groupby(bin(n)[2:])]))//prod(map(factorial,Counter(c).values())) # Chai Wah Wu, Mar 16 2023
Formula
a(n) = 1 iff n = 0 or n belongs to A140690.
Comments