https://github.com/mrvideo/collatz-visualiser
A Python script to plot the number sequence generated by a seed through the Collatz conjecture
https://github.com/mrvideo/collatz-visualiser
Last synced: 3 months ago
JSON representation
A Python script to plot the number sequence generated by a seed through the Collatz conjecture
- Host: GitHub
- URL: https://github.com/mrvideo/collatz-visualiser
- Owner: MrVideo
- License: mit
- Created: 2021-11-10T19:53:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-11T14:43:40.000Z (over 3 years ago)
- Last Synced: 2025-03-11T00:48:31.679Z (3 months ago)
- Language: Python
- Size: 2.93 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Collatz Conjecture Plot Visualiser
A Python script to plot the number sequence generated by a seed through the Collatz conjecture. Inspired by [Veritasium's video](https://www.youtube.com/watch?v=094y1Z2wpJg).
## What is the Collatz conjecture?
From [Wikipedia](https://en.wikipedia.org/wiki/Collatz_conjecture):
> The Collatz conjecture is a conjecture in mathematics that concerns sequences defined as follows: start with any positive integer n. Then each term is obtained from the previous term as follows: if the previous term is even, the next term is one half of the previous term. If the previous term is odd, the next term is 3 times the previous term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.## What does this script do?
This script takes a natural number greater or equal than one and follows the rules imposed by the conjecture to then gather an array of integers and plot them with ``matplotlib.pyplot``.
### Known problems
Very big integers converge to 0 instead of 1. I will try to solve this, but it might be caused by approximation errors, which are out of my control.