## Simple Collatz Conjecture (terminal/command prompt)

This is the place to post any code that you want to share with the community. Only completed scripts should be posted here.
Note: posts here are not necessarily endorsed by the community, and may represent amateur or even bad practices.

### Simple Collatz Conjecture (terminal/command prompt)

Code: Select all
`import time#-----def odd_even(n):   return n % 2 == 0def collatz(n):   o_e = odd_even(n)   if o_e == True:      n = n / 2   elif o_e == False:      n = n * 3 + 1   print n   return ndef collatzloop(n):   while n != 1:      n = collatz(n)def mainloop():   n = int(raw_input("What number do you want to start with?\n> "))   if n == 0:      print "You broke it, you know that?"      time.sleep(0.7)      print "Now, just sit back and wait for the singularity."      time.sleep(1)      exit()   while True:      while n != 1:         n = collatz(n)         time.sleep(0.2)      break#-----print "Collatz Conjecture Calculator"print "Version 1.0"print "Jan 12 2014\n"time.sleep(1)while True:   try:      mainloop()      while True:         again = raw_input("Do you want to do this again?\n> ")         if again.lower() in ['y', 'yes']:            break         elif again.lower() in ['n', 'no']:            exit()         else:            print "What? Try \"yes\" or \"no\""   except KeyboardInterrupt:      breakexit()`
Last edited by Mekire on Sat Feb 08, 2014 8:00 am, edited 1 time in total.
Reason: Locked.
Python 2.7
Mac Mini (Desktop/server)
Macbook Air
Laptop w/ Ubuntu 14.04
mckryall

Posts: 116
Joined: Sat Nov 23, 2013 6:13 pm