Question 111888
If you raise 3 to successive powers starting with 1, and then perform integer division on the result by 7, you get a repeating pattern of remainders that repeats every 6th time.


Use the modulo function which returns the remainder for an integer division: 
 
{{{3mod7=       3}}}
{{{9mod7=	2}}}
{{{27mod7=	6}}}
{{{81mod7=	4}}}
{{{243mod7=	5}}}
{{{729mod7=	1}}}
{{{2187mod7=	3}}}
{{{6561mod7=	2}}}
{{{19683mod7=	6}}}
{{{59049mod7=	4}}}
{{{177147mod7=	5}}}
{{{16777216mod7=1}}}


Now, 777777 mod 6 is 3 (mod 6 because it repeats every sixth time), so {{{3^(777777) mod 7}}} should yield the third item in the pattern, namely 6