day1/exercise/collatz.py
author Puneeth Chaganti <punchagan@fossee.in>
Fri, 10 Dec 2010 00:04:46 +0530
branchscipyin2010
changeset 449 49e10e9fc660
parent 425 5afcfce15e71
permissions -rw-r--r--
Fixed day2/session1.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