Created
August 3, 2021 10:26
-
-
Save arashrasoulzadeh/e8c5dbad36e287aa870fa8e9c86b2d24 to your computer and use it in GitHub Desktop.
Collatz Conjecture
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
number=100 | |
def odd(n): | |
return n % 2 != 0 | |
def calc(n): | |
print(n) | |
if odd(n): | |
n=(n*3)+1 | |
else: | |
n=n/2 | |
if n != 1: | |
return calc(n) | |
print(" and back to 1") | |
return | |
calc(number); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment