branch | scipy2010 |
changeset 425 | 5afcfce15e71 |
parent 386 | a0bec380b44f |
--- a/day1/exercise/collatz.py Sun Jun 27 20:23:10 2010 -0500 +++ b/day1/exercise/collatz.py Sun Jun 27 22:05:22 2010 -0500 @@ -1,8 +1,8 @@ -a = int( raw_input( 'Enter number: ') ) -while a != 4: - print a, - if a % 2 == 1: - a = a * 3 + 1 +num = int( raw_input( 'Enter number: ') ) +while num != 4: + print num, + if num % 2 == 1: + num = num * 3 + 1 else: - a /= 2 + num /= 2 print 4, 2, 1