Consider the recurrence relation:
$$x_{i+1}=p-1-((p \cdot i-1) \mod{x_i})$$
If $p$ is prime and $x_0=1$, what is the least period of the resulting (eventually periodic) sequence?
My guess is the minimal period equals $\text{lcm}(p-1,...,2)$ but I only rarely believe this and can't quite gather a convincing amount of numerical evidence.
Edit (1/19/17):
Suppose $p$ is composite. Should $\text{gcd}(x_{i_0},p)$ be greater than one for some $i_0$ then it is always greater than one thereafter. So findng a factor of $p$ reduces to computing $x_i$ for any large enough $i$.
The few experiments I have done suggest this sequence always (rather inefficiently) cracks $p$. Can anyone here find a counterexample?
Your guess is correct.
We can construct a table of $x_{i+1}$ with values of $(p\cdot i-1)$ as the y-axis and $x_i$ (the modulus) as the x-axis; considering the example of $p=5$ we have:
Note how $0 < x_i < p$, and how since $p$ is prime, the period of any column, $x_i$, will be $x_i$. This makes it easy to see that the period of the entire table (before rows begin repeating) is indeed $\text{lcm} (1, ..., p-1)$.
To see why this represents the period of the sequence in question, consider the fact that $x_{i+1}$ will be equal to the ${x_i}^{th}$ number in the $i^{th}$ row of the above table. For example $x_3 = 3$ so we go to the 3rd element of the third row (beginning with 14), and we get $x_4 = 2$. We then go to the 2nd element of the next row and we get $x_5 = 3$, and so on.
Considering this, it is clear that the period will be the lcm of every column which is visited at least once (so if it was the case that the value switched between the 2nd and 3rd columns, the period would only be 6). However, it is impossible for the sequence to not include each number at least once. This is because for any subset of the columns, there must be at least one row which is entirely comprised of a value not among those rows. Since each column will include numbers not in the subset, and since the columns are all coprime (and if not, can be equivalently represented by a set of coprime columns), a combination only including these numbers must occur at least once. This means that no matter what the previous value was, the next will have to be in an outside row.
I am only an enthusiast, and have little experience with trying to rigorously express my ideas; I tried to make my explanation as clear as I could but please feel free to ask for clarification if you see any lapse in logic or something difficult to understand.