Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # collatz_conjecture.py
- # finally solved by chatgpt?
- def collatz_conjecture(n):
- result = []
- def cc(n):
- if n == 1:
- return
- elif n % 2 == 0:
- v = n // 2
- result.append(v)
- cc(v)
- else:
- v = 3 * n + 1
- result.append(v)
- cc(v)
- cc(n)
- print(result)
- collatz_conjecture(10)
- collatz_conjecture(15)
- collatz_conjecture(99)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement