You can put this solution on YOUR website! 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:
Now, 777777 mod 6 is 3 (mod 6 because it repeats every sixth time), so should yield the third item in the pattern, namely 6