### Walter Carnielli's generalization of the 3x+1 mapping

The following mapping Td: ℤ → ℤ was defined in an email from Professor Walter Carnielli to Keith Matthews (26th December 2010).
Let d ≥ 2. Then

```                       Td(n) = n/d if n ≡ 0 (mod d)
Td(n) = ((d+1)n + d - i)/d if n ≡ i (mod d), 1 ≤ i ≤ d-1.
```
For example, d = 2 gives the 3x+1 mapping:
```                       T2(n) = n/2 if n ≡ 0 (mod 2)
T2(n) = (3n + 1)/2 if n ≡ 1 (mod 2).
```
This is a special case of a version of a mapping studied by Herbert Möller and also an example of a relatively prime mapping, in the language of Matthews and Watts, where m0=1 and mi = d+1 for 1 ≤ i < d and where we have the inequality
```
m0m1⋯md =(d+1)d-1 < dd.
```
So it seems certain that the sequence of iterates
```                       n, Td(n), Td2(n), ...
```
always eventually enters a cycle and that there are only finitely many such cycles as was conjectured by Professor Carnielli.

It is easy to prove that

• Td(n) = n for n = -1,...,-(d – 1);
• 1, 2,..., d is a cycle.
For d = 7,14, 18 and 21, we appear to get no cycles other than those in (i) and (ii).
It would be interesting to determine all d with this property. See the Table, which was constructed using the author's faster CALC program.

We search all trajectories x, Td(x), Td2(x),... where |x| ≤ R ⁄ 2 = 60000 ⁄ 2 for cycling by Floyd's method of testing for equality of kth and 2kth iterates for k ≤ U = 1000000.
Here we list cycles found other than those of cases (i) and (ii) for all d satisfying m ≤ d ≤ n, where m and n satisfy 2 ≤ m ≤ n ≤ 100.
We choose the cycle element with smallest absolute value as starting point.
Finally, we limit the number of cycles for each d to 500.

Enter m (2 ≤ m ≤ 100 ):
Enter n (m ≤ n ≤ 100 ):
print a complete cycle and the cycle-length
print only the start of a cycle and the cycle-length