Fix point of squaring numbers mod p

160 Views Asked by At

Take the set of integers $\{0, 1, .., p-1\}$, square each element, you get the (smaller) set of quadratic residues. Repeat until you get a fix point set. The size of this set is a function of $p$. Does this function have a name? How can I efficiently calculate it?

Some values: $$f(3) = 2, \\ f(5) = 2,\\ f(7) = 4,\\ f(11) = 6,\\ f(13) = 4, \\ f(17) = 2,\\ f(19) = 10,\\ f(23) = 12,\\ f(29) = 8$$

1

There are 1 best solutions below

4
On BEST ANSWER

Let us factor $p-1=2^am$, where $m$ is odd. The size of your terminal set is $m$. You are working with a cyclic group of order $p-1$. As $m$ is odd, the Chinese Remainder Theorem tells you that there is an isomorphism $$ \mathbb{Z}_p^*\cong C_m\times C_{2^a}. $$ Repeated squaring kills the $C_{2^a}$ after $a$ iterations, and squaring is bijective on $C_m$.

If you include $0$ (I didn't), then add one.