title: Best way to compute ((2^n )-1)mod p
body: <p>I'm working on a cryptographic exercise, and I'm trying to calculate (2<sup>n</sup>-1)mod p where p is a prime number</p>
  
  <p>What would be the best approach to do this? I'm working with C so 2<sup>n</sup>-1 becomes too large to hold when n is large</p>
  
  <p>I came across the equation (a*b)modp=(a(bmodp))modp, but I'm not sure this applies in this case, as 2<sup>n</sup>-1 may be prime (or I'm not sure how to factorise this)</p>
  
  <p>Help much appreciated.</p>