title: Special simple random number generator
body: <p>How to create a function, which on every call generates a random integer number? This number must be most random as possible (according to <a href="http://en.wikipedia.org/wiki/Uniform_distribution_%28discrete%29" rel="noreferrer">uniform distribution</a>). It is only allowed to use one static variable and at most 3 elementary steps, where each step consists of only one basic arithmetic operation of <a href="http://en.wikipedia.org/wiki/Arity" rel="noreferrer">arity</a> 1 or 2.</p>
  
  <p>Example:</p>
  
  <pre><code>int myrandom(void){
    static int x;
    x = some_step1;
    x = some_step2;
    x = some_step3;
    return x;
  }
  </code></pre>
  
  <p>Basic arithmetic operations are +,-,%,and, not, xor, or, left shift, right shift, multiplication and division. Of course, no rand(), random() or similar stuff is allowed.</p>