### Example 8 of G. Venturini

The iterates y, T(y), T(T(y)),... of the function

 T(x) = x/3 if x ≡ 0 (mod 6) T(x) = (x - 1)/3 if x ≡ 1 (mod 6) T(x) = (5x + 5)/3 if x ≡ 2 (mod 6) T(x) = (3x + 5)/2 if x ≡ 3 (mod 6) T(x) = (3x + 2)/2 if x ≡ 3 (mod 6) T(x) = (3x - 1)/2 if x ≡ 5 (mod 6)

are printed and the number of steps taken to reach one of the integers 0, -2, 2, 8, -10, -82, -52, 6038 is recorded.

Venturini gave an heuristic explanation as to why there should be everywhere cycling.
We believe that every trajectory will end up in one of the following 8 cycles:

cycle 1: 0
cycle 2: -2
cycle 3: 2, 5, 7
cycle 4: 8, 15, 25
cycle 5: -10, -15, -20, -29
cycle 6: -82, -135, -200, -299, -100, -165, -245
cycle 7: -52, -85, -128, -191, -64, -105, -155
cycle 8: 6038, 10065, 15100, 22651, 7550, 12585, 18880, 28321, 9440, 15735, 23605, 7868, 13115, 19672, 29509, 9836, 16395, 24595, 8198, 13665, 20500, 30751, 10250, 17085, 25630, 38446, 57670, 86506, 129760, 194641, 64880, 108135, 162205, 54068, 90115, 30038, 50065, 16688, 27815, 41722, 62584, 93877, 31292, 52155, 78235, 26078, 43465, 14488, 21733, 7244, 12075, 18115

This is an example where the Markov chain {Yn} has infinitely many states.
See G. Venturini, Iterates of Number Theoretic Functions with Periodic Rational Coefficients (Generalization of the 3x+1 Problem), Studies in Applied Mathematics, 86 (1992)185-218.

Enter M: