This problem describes that :
Given N, find the smallest number A that A^A divisible by N. (N<=1.000.000.000)
E.g: N=9 , output A=3 (3^3 mod 9=0) ; given N=6 output A=6 (6^6 mod 6=0).
I calculate from 1 until I find number appropriate, but during I calculate variable (A^A) then data overflow. How can I find number A faster and no data overflow?