title: Random Number Generator
body: <p>I need to write a program in Java to generate random numbers within the range [0,1] using the formula:</p>
  
  <blockquote>
    <p>X<sub>i</sub> = (aX<sub>i-1</sub> + b) mod m </p>
  </blockquote>
  
  <p>assuming any fixed int values of a, b &amp; m and X<sub>0</sub> = 0.5 (ie i=0)</p>
  
  <p>How do I go about doing this?</p>
  
  <p>i tried doing this but it's obviously wrong:</p>
  
  <pre><code>int a = 25173, b = 13849, m = 32768;
  double X_[i];
  for (int i = 1; i&lt;100; i++)
     X_[i] = (a*(X_[i]-1) + b) % m;
  double X_[0] = 0.5;
  double double = new double();
  System.out.println [new double];
  </code></pre>