Created
April 29, 2016 21:27
-
-
Save Neemox/385b326df38884d975da75f8f0213bb3 to your computer and use it in GitHub Desktop.
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
def collatz(): | |
global number | |
if number % 2 == 0: | |
number = number // 2 | |
print(number) | |
return number | |
else: | |
number = number * 3 + 1 | |
print(number) | |
return number | |
print('Please enter a number for the Collatz sequence:') | |
number = int(input()) | |
while number != 1: | |
collatz() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment