Let the number be .

Let .

Then .

Therefore .

By backwards argument it's easy to see that all the cycles in are solutions.

Thus we have found all the solutions, the smallest of which is .

This technique can be applied to this kind of problems in many cases.