Putting the problem in terms of modular arithmetic, we are trying to reduce 32^(32^32)323232 modulo 77, that is
32^(32^32)" (mod 7)"323232 (mod 7)
As 3232 and 77 are coprime integers, we know by Euler's theorem that
32^(varphi(7)) -= 1" (mod 7)"32φ(7)≡1 (mod 7)
where varphiφ is Euler's totient function. Because 77 is prime, we can easily calculate varphi(7)φ(7) as 7-1 = 67−1=6. With that, if we have 32^32=6q+r3232=6q+r for positive integers qq and rr, we can rewrite the problem as
32^(32^32) -= 32^(6q+r)" (mod 7)"323232≡326q+r (mod 7)
-= 32^r 32^(6q)" (mod 7)"≡32r326q (mod 7)
-= 32^r(32^6)^q" (mod 7)"≡32r(326)q (mod 7)
-=32^r(32^(varphi(7)))^q" (mod 7)"≡32r(32φ(7))q (mod 7)
-=32^r(1)^q" (mod 7)"≡32r(1)q (mod 7)
-=32^r" (mod 7)"≡32r (mod 7)
To find rr, then, we look at 32^32" (mod 6)"3232 (mod 6). Without needing any tricks, we can observe that for any integer k>0k>0, we have
{(2^(2k+1)-=2" (mod 6)"), (2^(2k)-=4" (mod 6)"):}
=>32^32 -= (2^5)^32 -= 2^(5*32) -= 2^(2*80) -= 4" (mod 6)"
With the work above, that gives us
32^(32^32) -= 32^4" (mod 7)
There are many ways to proceed from here, but noting that 2 and 7 are coprime, let's use the totient function again.
32^4 -= (2^5)^4" (mod 7)"
-=2^20" (mod 7)"
-=2^2(2^18)" (mod 7)"
-=4(2^(6*3))" (mod 7)"
-=4(2^6)^3" (mod 7)"
-=4(2^(varphi(7)))^3" (mod 7)"
-=4(1)^3" (mod 7)"
-=4" (mod 7)"