Is there some general technique to compute tetration and pentation mod some number?
$m \uparrow^2 n \pmod a$ and $m \uparrow^3 n \pmod a$
I know about Euler's theorem to compute $m \uparrow n \pmod a$, but expanding pentation would result in huge tower.
Specifically, I want to compute in reasonable time Ackermann mod-a function "$ 2 \uparrow^{m-2} n \pmod a$".