reviewed
approved
reviewed
approved
proposed
reviewed
editing
proposed
a((2^(m+2)-k) = A007306(2^(m+1)-k), m=0,1,2,..., k=0,1,2,...,2^m-1. - Yosu Yurramendi, Jul 04 2014
approved
editing
proposed
approved
editing
proposed
SternBrocotTreeNum := proc(n) option remember; local msb, r; if(n < 2) then RETURN(n); fi; msb := floor_log_2(n); r := n - (2^msb); if(floor_log_2(r) = (msb-1)) then RETURN(SternBrocotTreeNum(r) + SternBrocotTreeNum(((3*(2^(msb-1)))-r)-1)); else RETURN(SternBrocotTreeNum((2^(msb-1))+r)); fi; end; # Antti Karttunen, Mar 19 2000 [Broken program - N. J. A. Sloane, Aug 05 2020]
if ilog2(r) = msb - 1 then b(r) + b(3*2^(msb-1) - r - 1) else b(2^(msb - 1) + r) fi end: if n = 0 then 0 else b(n-1) fi end: # _Antti Karttunen_, Mar 19 2000 [Corrected and rewritten by _Peter Luschny_, Apr 24 2024]
# Antti Karttunen, Mar 19 2000 [Corrected and rewritten by Peter Luschny, Apr 24 2024]
A007305 := proc(n) local b; b := proc(n) option remember; local msb, r;
if n < 3 then return 1 fi; msb := ilog2(n); r := n - 2^msb;
if ilog2(r) = msb - 1 then b(r) + b(3*2^(msb-1) - r - 1) else b(2^(msb - 1) + r) fi end: if n = 0 then 0 else b(n-1) fi end:
# Antti Karttunen, Mar 19 2000 [Corrected and rewritten by Peter Luschny, Apr 24 2024]
seq(A007305(n), n = 0..92);
approved
editing
proposed
approved