And now I did #zsh :
https://rosettacode.org/wiki/Modular_exponentiation#zsh
But really it is #GNU #expr doing the work. I had considered using GNU #bc instead. Basically anything that can do the calculation. Unix-users in the old days often liked hoc; maybe there is a hoc implementation you could use. :)
#zsh #gnu #expr #bc #zshell #rosettacode