day1/exercise/collatz.py
author Puneeth Chaganti <punchagan@fossee.in>
Thu, 09 Dec 2010 23:11:12 +0530
branchscipyin2010
changeset 448 dc8d666a594a
parent 425 5afcfce15e71
permissions -rw-r--r--
Changed date format in day1/session{3,4,5}.tex.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
425
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     1
num = int( raw_input( 'Enter number: ') )
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     2
while num != 4:
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     3
    print num,
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     4
    if num % 2 == 1:
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     5
        num = num * 3 + 1
64
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     6
    else:
425
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     7
        num /= 2
386
a0bec380b44f Major edits.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 354
diff changeset
     8
print 4, 2, 1