title: modular exponentation funcation generate incorrect result for big input in c
body: <p>I try two function for modular exponentiation for big base return wrong results,
  One of the function is:</p>
  
  <pre><code>uint64_t modular_exponentiation(uint64_t x, uint64_t y, uint64_t p) 
  { 
      uint64_t res = 1;      // Initialize result 
      x = x % p;  // Update x if it is more than or  
                  // equal to p 
      while (y &gt; 0) 
      { 
          // If y is odd, multiply x with result 
          if (y &amp; 1) 
              res = (res*x) % p;   
          // y must be even now 
          y = y&gt;&gt;1; // y = y/2 
          x = (x*x) % p;   
      } 
      return res; 
  }
  </code></pre>
  
  <p>For input <code>x = 1103362698 ,y = 137911680 , p=1217409241131113809;</code>
  It return the value <code>(x^y mod p)</code>:<code>749298230523009574</code>(Incorrect). </p>
  
  <p>The correct value is:<code>152166603192600961</code></p>
  
  <p>The other function i try, gave same result, What is wrong with these functions?
  The other one is : </p>
  
  <pre><code>long int exponentMod(long int A, long int B, long int C) 
  { 
      // Base cases 
      if (A == 0) 
          return 0; 
      if (B == 0) 
          return 1; 
      // If B is even 
      long int y; 
      if (B % 2 == 0) { 
          y = exponentMod(A, B / 2, C); 
          y = (y * y) % C; 
      } 
      // If B is odd 
      else { 
          y = A % C; 
          y = (y * exponentMod(A, B - 1, C) % C) % C; 
      }   
      return (long int)((y + C) % C); 
  } 
  </code></pre>