#include
using namespace std;
/*
* Via OEIS.org: "The 3x+1 or Collatz problem is
* as follows: start with any number n. If n is
* even, divide it by 2, otherwise multiply it
* by 3 and add 1. Do we always reach 1? This
* is a famous unsolved problem. It is conjectured
* that the answer is yes." #HailstoneNumbers
*
* @creator gdt
* @created 02017.03.27
* @updated 02017.11.03 change #define MAX_N to const int
* @oeis http://oeis.org/A006577
* "Number of halving and tripling steps
* to reach 1 in '3x + 1' problem."
* @note Numberphile posted "Collatz Conjecture in Color"
* the day after this program was written.
* https://youtu.be/LqKpkdRRLZw
*/
void doit(int n) {
cout << n << "...";
int count = 0;
while (n != 1) {
if (n % 2)
n = n * 3 + 1;
else
n /= 2;
count++;
}
cout << count << endl;
}
int main(int,char**) {
const int MAX_N = 128;
for (int n = 1; n <= MAX_N; n++)
doit(n);
}