# Period of $x^n \mod y$?

Let $x$, $y$, $n$ be positive integers. Where $n$ and $y$ shall be constants and $x$ a variable. Then it is trivial that the period of

$x \bmod y$

in $x$ is $y$, since the function simply drops to zero and starts over when $x$ reaches $y$. Now, for me at least, it is much less obvious, what the period of

$x^n \bmod y$

in $x$ should be. Visually (looking at plots of the function at different $n$ and $y$) the results suggest that the period still stays $y$. How can I see that analytically?

-
What does period mean? – William Aug 20 '12 at 23:09
If by period you mean order in a group then you're mistaken if you mean multiplication or addition. For instance, $2+2 \equiv 0 \pmod 4$ and $2 \times 2 \equiv 1 \pmod 3$, so $2$ has order $2$ in modulo-$4$ arithmetic under addition, and order $2$ in modulo-$3$ arithmetic under multiplication. – Clive Newstead Aug 20 '12 at 23:11
@William: the period $p$ is the smallest positive integer such that $(x+p)^n \equiv x^n\pmod y$. – MJD Aug 20 '12 at 23:11
The OP wants the period as a function in $x$, not as a function in $n$. – Qiaochu Yuan Aug 20 '12 at 23:12
I am sorry, I am not a native speaker. I mean period just as $2\pi$ for $\sin(x)$. – Fejwin Aug 20 '12 at 23:12

There are many cases where the period is $y$ (and, as Andre points out, many cases where it is not). If $y$ is squarefree (that is, if there is no integer $d\gt1$ such that $y$ is a multiple of $d^2$), then $x^n$ is zero if and only if $x$ is 0 (modulo $y$), so the period has to be $y$.
The period need not be $y$. For example, let $y=9$, and consider the function $x^3$. This has period $3$. One can build many similar examples.