### Generalized 3x+1 functions and trajectory frequencies (mod m)

We study a function T: ℤ→ℤ with d (> 1) branches, defined in terms of d non-zero integers m0,...,md-1 and d integers X0,...,Xd-1.

Then T(x)=int(mix ⁄ d)+Xi, if x≡ i (mod d).

Example. The 3x+1 mapping T(x)=x ⁄ 2 if x is even, (3x+1) ⁄ 2 if x is odd, corresponds to m0=1, m1=3, x0=0, x1=1.

Starting in 1982, Tony Watts and I investigated the frequencies of occupation of congruence classes (mod M)
of trajectories arising from generalized 3x+1 functions. (See earlier 3x+1 interests)

Experimentally we observed that all trajectories exhibited a limiting frequency of occupation of congruence classes (mod M).

The present program prints these frequencies for the iterates x, T(x), T2(x), ...,Tk-1(x)

Enter d (1 < d ≤ 10):
Enter M (1 < M ≤ 100):
Enter the d non-zero integers mi (separated by spaces):
Enter the d integers Xi (separated by spaces):
Enter the start x of the trajectory:
Enter the number of iterates k:(1 < k ≤ 50000):