Friday, June 29, 2012

Collatz conjecture


Rem  http://en.wikipedia.org/wiki/Collatz_conjecture#Methods_of_proof
graphsize 1000,400
for x = 1 to 1000
a=x
n=0
do
b=a
if a/2 = int(a/2) then
a = a/2
else
a=a*3+1
end if
n=n+8
line n-8,400-b/30,n,400-a/30
until a = 1
print "Initial number "+x+ " Iterations "+n/8
next x

No comments:

Post a Comment