title: Modular Exponentiation
body: <p>In C/C++ how can I calculate <code>(a^b)%m</code> where <code>b</code> does not fit into 64 bits? In other words, is there a way of calculating the above value using <code>b%m</code> instead of <code>b</code>?</p>
  
  <p>And is there any algorithm that can compute the above result in <code>O(log(b))</code> time or <code>O(log(b%m))</code> time?</p>