Uses 180 bytes, for the more conventional counters...
68/13, 133/102, 341/51, 115/17, 17/19, 87/161, 17/23, 23/29, 53/93,
26973/217, 410/259, 43/111, 976/37, 37/41, 329/215, 37/43, 43/47,
118/265, 1/53, 53/59, 67/305, 1/61, 61/67, 117/4
Try it online!
Am a bit lazy to add an explanation now; happy to do so if it gets attention/upvotes! However, I do have some notes for when I first wrote up the Collatz Conjecture code which you can run here. It's almost the same, but the TIO command line arguments are set to print every number in the sequence along the way, which makes it less of a blackbox!
State Diagrams for COLLATZGAME
Here are the state diagrams, for which I used Conway's original notation which he presents in this article.
The above is simply to calculate the Collatz sequence for
n given an input of the form
2^n. The only change I made to also keep count of the steps taken was to make the 1/3 from states Q -> D into an 11/3, 11 being the smallest unused prime. This fraction is only executed once for every number in the sequence; it's the state that figures out whether the number is even or odd to figure out what's next. Therefore, the
11 prime register is incremented once per number in the sequence, except one, yielding the number of steps.
I simply encoded the state diagram as below and wrote an interpreter which did the dirty work. However, the work done to convert a state diagram to FRACTRAN is also detailed in Conway's article above:
- A: 9/4 -> T
- T: 4/1 -> Q
- Q: 7/6*, 11/3 -> D, 5/1 -> R
- R: 3/7*|Q
- D: 1/3 -> E, 729/7 -> M
- M: 10/7*, 1/3 -> N, 16/1 -> O
- N: 7/5*|M
- E: 2/5*|A
- O: 1/5*|A