OFFSET
0,3
COMMENTS
Leading zeros may appear in binary words w_2, ..., w_{k-1}.
a(n) gives the number of ways to erase the binary expansion of n bit by bit.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..8192
Rémy Sigrist, PARI program
Natalia L. Skirrow, bitwise permutations
FORMULA
a(n) = 1 iff n belongs to A000225.
a(2^k) = k + 1 for any k >= 0.
a(n) >= A367019(n).
a(n) <= A383254(n). (See comment there) - Natalia L. Skirrow, Apr 20 2025
EXAMPLE
For n = 5:
- the binary expansion of 5 is "101",
- we have the following appropriate sequences of binary words:
("101", "11", "1", "")
("101", "10", "1", "")
("101", "10", "0", "")
("101", "01", "1", "")
("101", "01", "0", "")
- hence a(5) = 5.
PROG
(PARI) \\ See Links section.
(Python)
def A368070(n):
m=0
r=[1]
for k in range(n.bit_length()):
if m!=(m:=n>>k&1): r=r[::-1]
for j in range(k): r[j+1]+=r[j]
r.insert(0, 0)
return sum(r) # Natalia L. Skirrow, Apr 20 2025
(Python)
from fractions import Fraction as frac
inte=lambda p: [0]+[frac(c, i+1) for i, c in enumerate(p)]
from math import factorial as fact
def A368070(n):
r=[1]
for k in range(n.bit_length()):
i=inte(r)
r=i if n>>k&1 else [sum(i)]+[-c for c in i[1:]]
return int(fact(n.bit_length()+1)*sum(inte(r)))
#without the multiplication, this is the probability that a sequence of real numbers in [0, 1] satisfies the chain of inequalities. # Natalia L. Skirrow, Apr 20 2025
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Dec 10 2023
STATUS
approved
