Putting the problem in terms of modular arithmetic, we are trying to reduce #32^(32^32)# modulo #7#, that is
#32^(32^32)" (mod 7)"#
As #32# and #7# are coprime integers, we know by Euler's theorem that
#32^(varphi(7)) -= 1" (mod 7)"#
where #varphi# is Euler's totient function. Because #7# is prime, we can easily calculate #varphi(7)# as #7-1 = 6#. With that, if we have #32^32=6q+r# for positive integers #q# and #r#, we can rewrite the problem as
#32^(32^32) -= 32^(6q+r)" (mod 7)"#
#-= 32^r 32^(6q)" (mod 7)"#
#-= 32^r(32^6)^q" (mod 7)"#
#-=32^r(32^(varphi(7)))^q" (mod 7)"#
#-=32^r(1)^q" (mod 7)"#
#-=32^r" (mod 7)"#
To find #r#, then, we look at #32^32" (mod 6)"#. Without needing any tricks, we can observe that for any integer #k>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)"#