OFFSET
0,5
COMMENTS
This sequence has similarities with A090706; here we consider multisets of run-lengths, there multisets of digits in binary expansions.
LINKS
FORMULA
a(n) = 1 iff n = 0 or n belongs to A140690.
EXAMPLE
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.
PROG
(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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Mar 13 2023
STATUS
approved