An Interesting Sequence of Cyclic Digits

Consider the following little problem:

Problem:

Given a three-digit number as the first term of a sequence, like 599, define f as: f(599)=[(5+9) mod 10] [(9+9) mod 10] [(9+5) mod 10]. So the function takes 599 to 484. If you apply f again, you get: 228, 400, 404, 448, ...etc. Continue this way, producing new terms. Will those terms cycle?

Proof:

(by Robert Israel) f is not periodic, but it is eventually periodic. The formulation in terms of three-digit numbers is a red herring. What you really have is a map on (Z10)3 f(x,y,z) = (x+y, y+z, z+x) where Z10 is the integers mod 10. Clearly the range of f is contained in R = {(x,y,z): x+y+z is even}. In fact it is equal to R, because for any x, y, z with x+y+z=2w, f(w-y,w-z,w-x) = (2w-y-z,2w-z-x,2w-x-y) = (x,y,z). On R, f is periodic: f(12) (x,y,z) = 5 (x+y+z) (1,1,1) + (x,y,z) = (x,y,z) if x+y+z is even. The period of any given element divides 12:

In your example, (5,9,9) is not in R, but f(5,9,9)=(4,8,4) which has period 12.

After Robert's proof, here is some Maple code to view the cycles:

> f:=proc(L)
> local NL,len,i;
> len:=nops(L);NL:=[];
> for i from 1 to len-1 do
> NL:=[op(NL),L[i]+L[i+1] mod 10];
> od;
> NL:=[op(NL),L[len]+L[1] mod 10];
> end:
> Orbit:=[[0,1,9]];# orbit seed
> for n from 1 to 13 do
> Orbit:=[op(Orbit),f(Orbit[nops(Orbit)])];
> od:
> with(plots):
> pointplot3d(Orbit,connect=true);

And here are some orbits in 3-D:

orbit 3
Period 3: [5, 5, 0],[0, 5, 5],[5, 0, 5].
orbit 4
Period 4: [2, 2, 2],[4, 4, 4],[8, 8, 8],[6, 6, 6].
orbit 6
Period 6: [3, 5, 2],[8, 7, 5],[5, 2, 3],[7, 5, 8],[2, 3, 5],[5, 8, 7].
orbit 12
Period 12: [0, 0, 4],[0, 4, 4],[4, 8, 4],[2, 2, 8],[4, 0, 0],[4, 0, 4],[4, 4, 8],[8, 2, 2],[0, 4, 0],[4, 4, 0],[8, 4, 4],[2, 8, 2].
orbit 122
Eventually period 12: [5, 9, 9],[4, 8, 4],[2, 2, 8],[4, 0, 0],[4, 0, 4],[4, 4, 8],[8, 2, 2],[0, 4, 0],[4, 4, 0], [8, 4, 4],[2, 8, 2],[0, 0, 4],[0, 4, 4].