Skip to content

Instantly share code, notes, and snippets.

@kurzweil777
Last active April 26, 2020 15:35
Show Gist options
  • Save kurzweil777/d077681fc2acbd68d7cb04d5842d2d06 to your computer and use it in GitHub Desktop.
Save kurzweil777/d077681fc2acbd68d7cb04d5842d2d06 to your computer and use it in GitHub Desktop.
Collate Sequence
def collatz(number):
global result
if number % 2 == 0:
result = number // 2
return result
elif number % 2 == 1:
result = 3 * number + 1
return result
try:
users_number = int(input("Введите целое число: "))
except ValueError:
print ("Вы ввели не целое число")
exit()
result = collatz(users_number)
while result != 1:
result_after = collatz(result)
print(result_after)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment