This function checks for the Collatz conjecture for a given number.
It can be customized to check other variants different to 3n+1
Takes a number n. If it’s even, divide by 2. If it’s odd, multiply by 3 and add 1. Repeat. Do all starting numbers lead to 1?
Edgar Guevara (2021). collatz (https://github.com/guevaracodina/collatz), GitHub. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.