0

Let $~p~$ be prime and $~n~$ some positive integer below $~10^9$. Is there an efficient way to compute product $~ \phi(1) \cdots \phi(n) \mod p~$? It is known that $~p > \sqrt{n}~$ (i don't know if this somehow can help). I know how to compute values $~\phi(1), \cdots, \phi(n)~$ using sieve but memory limitations are too strict to keep them all. Isn't there more efficient approach when we need to deal with such product? May be there is some nice formula for it?

Thanks in advance for any ideas.

P.P.S. The original problem is http://www.e-olymp.com/en/problems/3243

Igor
  • 2,153
  • 16
  • 19
  • You are incorrect on one point: if $n = 2p$ for some prime $p \geq 3,$ then $p > \sqrt n.$ Where did you come upon this problem? – Will Jagy Mar 19 '16 at 00:39
  • Nope, i'm right. In your example $\phi(2p) = p - 1 \not\equiv 0 \mod p$ – Igor Mar 19 '16 at 02:54

0 Answers0