title: How can I generate a random BigInteger within a certain range?
body: <p>Consider this method that works well:</p>
  <pre><code>public static bool mightBePrime(int N) {
      BigInteger a = rGen.Next (1, N-1);
      return modExp (a, N - 1, N) == 1;
  }
  </code></pre>
  <p>Now, in order to fulfill a requirement of the class I'm taking, <code>mightBePrime</code> must accept a <code>BigInteger</code> N, but that means that I need a different way to generate my random <code>BigInteger</code> <code>a</code>.</p>
  <p>My first idea was to do something like <code>BigInteger a = (N-1) * rGen.NextDouble ()</code>, but a <code>BigInteger</code> can't be multiplied by a <code>double</code>.</p>
  <p>How can I generate a random <code>BigInteger</code> between 1 and N-1, where N is a <code>BigInteger</code>?</p>