Created
April 27, 2013 22:37
-
-
Save rafkhan/5475032 to your computer and use it in GitHub Desktop.
Saw this on /g/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = 1 | |
sent = 1 | |
def n_divide(): | |
global n | |
n = (n/2) | |
def n_add(): | |
global n | |
n = ((3 * n) + 1) | |
def logic(): | |
global sent | |
n = int(input("Please enter a number")) | |
if (n == 1): | |
print("Done") | |
sent += 1 | |
else: | |
if (n % 2 == 0): | |
n_divide() | |
if (n == 1): | |
print("done") | |
sent += 1 | |
else: | |
logic() | |
else: | |
n_add() | |
n_divide() | |
if (n ==1): | |
print ("Done") | |
sent += 1 | |
else: | |
logic() | |
def menu(): | |
print("") | |
print("Press 'r' to run.") | |
print("Press 'q' to quit.") | |
print("Press 'm' to access the menu.") | |
print("") | |
def main(): | |
global sent | |
while (sent != 0): | |
menu() | |
user = input("") | |
if r in user: | |
logic() | |
elif m in user: | |
menu() | |
elif q in user: | |
sent = 0 | |
else: | |
print("Invalid input") | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment