A simple Math Problem

Revision en1, by Frankenstein123, 2019-07-08 15:36:26

Let's suppose I need to calculate $$$a^{b^{c}}$$$ modulo $$$10^9 + 7$$$, with the constraints $$$1 \leq a, b, c \leq 10^{18}$$$. I can calculate $$$ans = b^c$$$ in $$$\mathcal{O}(log(c))$$$, with modulo $$$10^9 + 6$$$, (probably everyone knows how) and then calculate $$$a^{ans}$$$ with modulo $$$10^9 + 7$$$.

But how does first taking $$$10^9 + 6$$$ and then $$$10^9 + 7$$$ work? Can anyone present a formal proof for this? Also are there any other methods to do this?

Tags math, fast power, #modular_theory

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Frankenstein123 2019-07-08 15:36:26 454 Initial revision (published)