Last active
January 14, 2023 11:07
-
-
Save sharpicx/cc1ca593f2e9614b3e6808994ba51658 to your computer and use it in GitHub Desktop.
collatz conjecture, the fabulous unsolved problems in math.
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
## https://www.mathcelebrity.com/collatz.php?num=+109&pl=Show+Collatz+Conjecture | |
## https://goodcalculators.com/collatz-conjecture-calculator/ | |
## sharpicx | |
def collatz(num): | |
i = [num] | |
while num != 1: | |
if num % 2 == 1: | |
num = 3 * num + 1 | |
else: | |
num //= 2 | |
if num <= 256: # basic ascii chars sampai ke extended codes dengan total 256 karakter. | |
i.append(num) | |
return i | |
def main(): | |
num = int(input('masukkan angka> ')) | |
print(collatz(num)) ## bilangan prima | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment