title: Finding modulo inverse if gcd is not 1
body: <p>I have to find (p^e-1)/(p-1) mod 1000000007, where p is a prime number.
  if gcd(p-1,1000000007) is not 1, then the modular inverse of (p-1) is not defined. Also, (p^e-1) is divisible by (p-1) (sum of a Geometric Progression). Also I can't find (p^e-1) since p,e&lt;=10^18. So how do I find (p^e-1)/(p-1) mod 1000000007</p>