Skip to content

Instantly share code, notes, and snippets.

@sharpicx
Last active January 14, 2023 11:07
Show Gist options
  • Save sharpicx/cc1ca593f2e9614b3e6808994ba51658 to your computer and use it in GitHub Desktop.
Save sharpicx/cc1ca593f2e9614b3e6808994ba51658 to your computer and use it in GitHub Desktop.
collatz conjecture, the fabulous unsolved problems in math.
## 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