The Collatz conjecture postulates that if you take any positive integer, then repeat the following algorithm enough times:
if number is odd, then multiply by three and add one
if number is even, then divide by two
you'll eventually end up at 1. It seems to always work, but it's never been proven that it always does.
You've already golfed calculating how long it takes to get to 1, so I thought I'd switch things up a bit.
Starting with a given positive integer, calculate how long it takes to get to 1 (its "stopping time"). Then find that number's stopping time.
Repeat until you get to 1, or until you get to the entirely arbitrary limit of 100 iterations. In the former case, print how many iterations it took. In the latter case, print "Fail" or some other consistent output of your choice, as long as it's not an integer 1≤n≤100
. You may not output an empty string for this option. Outputting an integer outside of the range [1, 100], however, is allowed.
Examples:
Input: 2
2->1
Output: 1
Input: 5
5->5->5->5->5->...
Output: Fail
Input: 10
10->6->8->3->7->16->4->2->1
Output: 8
Input: 100
100->25->23->15->17->12->9->19->20->7->16->4->2->1
Output: 13
Input: 10^100
10^100->684->126->108->113->12->9->19->20->7->16->4->2->1
Output: 13
Input: 12345678901234567890
12345678901234567890->286->104->12->9->19->20->7->16->4->2->1
Output: 11
Input: 1
--Depending on your code, one of two things may happen. Both are valid for the purposes of this question.
1
Output: 0
--Or:
1->3->7->16->4->2->1
Output: 6
As I calculated 10^100
and 12345678901234567890
using a language that only supports reals for that size, if your language is more accurate you may get different results for those.
Scoring
As this is code-golf, the answer with the shortest amount of bytes wins.