SPOJ WA Toutient function

Problem Link:-

I am getting correct output for all inputs with in the constraints !
I don`t understand why am i getiing WA?
Kindly please help me out !

I have used sieve for prime factorisation with precomputation (upto 10^6)
and store all the unique prime factors of given input in arraylist
and computed the phi using the n*(1-1/p) formula.

Code Link:-