Skip to content

Instantly share code, notes, and snippets.

@hovissimo
Last active April 29, 2016 22:21
Show Gist options
  • Save hovissimo/3051080c83412fed8775ea8324b0de46 to your computer and use it in GitHub Desktop.
Save hovissimo/3051080c83412fed8775ea8324b0de46 to your computer and use it in GitHub Desktop.
def get_number()
while (!num): # We'll keep trying until num has a value in it
try:
num = int(input()) # Prompt for a number
except ValueError: # If we couldn't make it an int...
print("enter an integer") # ... complain
return num
def collatz_next(n):
# return next number after n in the collatz sequence
pass
def print_collatz_sequence(n):
# keep reducing n until you get to 1, printing along the way
# this will call collatz_next in a loop of some kind
pass
def main():
number = get_number()
print_collatz_sequence(number)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment