Created
May 10, 2019 06:38
-
-
Save AgnieszkaUcinska/23b963cf287cd7e416f37367dd3a85c0 to your computer and use it in GitHub Desktop.
druga wersja
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(number): | |
| if number % 2 == 0: | |
| print(number // 2) | |
| return number // 2 | |
| elif number % 2 == 1: | |
| result = 3 * number + 1 | |
| print(result) | |
| return result | |
| n = input("Give me a number: ") | |
| while n != 1: | |
| n = collatz(int(n)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment