title: Is there an algorithm for calculating the multiplicative order of x modulo y (for y < 1000) that doesn't require a BigInteger type?
body: <p>The algorithm I'm using at the moment runs into extremely high numbers very quickly.  A step in the algorithm I'm to raises <strong>x</strong> to the result of the totient function applied to <strong>y</strong>.  The result is that you can run into very large numbers.</p>
  
  <p>Eg.  When calculating the <a href="http://en.wikipedia.org/wiki/Multiplicative_order" rel="nofollow noreferrer">multiplicative order</a> of 10 modulo 53:</p>
  
  <pre><code>10^totient(53) == 10^52 == 1 * 10^52
  </code></pre>
  
  <p>The following algorithm fares a bit better either in terms of avoiding large numbers, but it still fails where <strong>10^mOrder</strong> is greater than the capacity of the data type:</p>
  
  <pre><code>  mOrder = 1
    while 10^mOrder % 53 != 1
        if mOrder &gt;= i
            mOrder = 0;
            break
        else
            mOrder = mOrder + 1
  </code></pre>