Last active
June 12, 2020 23:44
-
-
Save sguzman/0899b8ec13f8bbdd0892d4618f112799 to your computer and use it in GitHub Desktop.
Simple funcs for studying the collatz conjecture in Mathematica. Not gonna lie, pretty proud of this.
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
collatz[1] = 1 | |
collatz[n_Integer /; And[n > 1, OddQ[n]]] := collatz[n] = 3 n + 1 | |
collatz[n_Integer /; And[n > 1, EvenQ[n]]] := collatz[n] = n / 2 | |
collatzseq[1] = {1} | |
collatzseq[n_Integer /; n > 1] := collatzseq[n] = {n, Splice@collatzseq@collatz@n} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment