777^777%1000... The worst remainder problem ever...

all conventional Euler, reverse Euler, CRT were useless.. The best method was using a calculator

, but here is the next best method,
777^777%1000,
E(125)=100
E(

= 4
777^100%125 = 777^4%8 = 1
hence taking lcm, 777^100%1000 = 1
so the problem reduces to 777^77%1000
777(603729)^38%1000 =1
777*(729)^38 = 1
777*3^228%1000 = 1
=777*3^28
=777*(3^7)^4
=777*(2187)^4
=777*187^4%1000
=777*969^2 =
697
had to do a lot of multiplication.. phew!!!!
@sachin.. buddy this is the correct answer...
@konda... pls suggest if there is any other better method?? using the Inverse Euler I was stuck at 777.x%1000 = 1 or 223.x%1000 = 999
the calue of x in both the cases exceeded the number itself(i gave up after that)..