title: Modulo of Division of Two Numbers
body: <p>we know that</p>
  
  <pre><code>(A + B) % P = (A % P + B % P) % P
  (A * B) % P = (A % P * B % P) % P
  </code></pre>
  
  <p>where <code>P</code> is a prime .</p>
  
  <p>I need to calculate <code>(A / B) % P</code> where <code>A,B</code> can be very large and can overflow .</p>
  
  <p>Does such kind of formula for modular arithmetic holds for <code>(A / B) % P</code> and <code>(A - B) % P</code>.</p>
  
  <p>If not then please explain what the correct answer is.</p>
  
  <p>I.e is it true that <code>(A / B) % P = ((A % P) / (B % P)) % P</code>?</p>
  
  <p>I WAS TRYING TO CALULATE (N*(N^2+5)/6)%P where N can be as large as 10^15</p>
  
  <p>here A=n*(n^2+5) can surely overflow for n=10^15</p>