day1/exercise/collatz.py
author Christopher Burns <chris.d.burns@gmail.com>
Sun, 27 Jun 2010 22:05:22 -0500
branchscipy2010
changeset 425 5afcfce15e71
parent 386 a0bec380b44f
permissions -rw-r--r--
REF: Reformat some of the exercises so they're easier to read for the audience.

num = int( raw_input( 'Enter number: ') )
while num != 4:
    print num,
    if num % 2 == 1:
        num = num * 3 + 1
    else:
        num /= 2
print 4, 2, 1