title: Calculate n where a^n mod m = 1?
body: <p>What is fastest way to calculate the first n satisfying the equation</p>
  
  <blockquote>
    <p>a^n mod m = 1</p>
  </blockquote>
  
  <p>Here a,n,m can be prime or composite
  mod : is the modulus operator</p>