25.11.2014 Views

Explorations of the Collatz Conjecture - Moravian College

Explorations of the Collatz Conjecture - Moravian College

Explorations of the Collatz Conjecture - Moravian College

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appendix A<br />

Branch Count Procedure<br />

branchcount:=proc(b, k, c)<br />

# counts <strong>the</strong> number <strong>of</strong> integers at height k above an integer b<br />

# assuming that b is at height c<br />

local count,w,s,v,r;<br />

if b=1 or b=2 <strong>the</strong>n<br />

# this is taking care <strong>of</strong> <strong>the</strong> base case.<br />

if k>2 <strong>the</strong>n return(branchcount(4, k, 2));<br />

else return(1);<br />

fi;<br />

elif b=2ˆc <strong>the</strong>n count:=1;<br />

else count:=0;<br />

# count <strong>the</strong> integer 2ˆk<br />

# don’t double-count anything else<br />

fi;<br />

if b mod 3 = 0 <strong>the</strong>n count:=count+0;<br />

47

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!