title: Does "n * (rand() / RAND_MAX)" make a skewed random number distribution?
body: <p>I'd like to find an unskewed way of getting random numbers in C (although at most I'm  going to be using it for values of 0-20, and more likely only 0-8). I've seen this formula but after running some tests I'm not sure if it's skewed or not. Any help?</p>
  
  <p>Here is the full function used:</p>
  
  <pre><code>int randNum() 
  { 
      return 1 + (int) (10.0 * (rand() / (RAND_MAX + 1.0)));
  }
  </code></pre>
  
  <p>I seeded it using:</p>
  
  <pre><code>unsigned int iseed = (unsigned int)time(NULL);
  srand (iseed);
  </code></pre>
  
  <p>The one suggested below refuses to work for me I tried</p>
  
  <pre><code>int greek; 
  for (j=0; j&lt;50000; j++) 
  { 
  greek =rand_lim(5); 
  printf("%d, " greek); 
  greek =(int) (NUM * (rand() / (RAND_MAX + 1.0))); 
  int togo=number[greek]; 
  number[greek]=togo+1; 
  }
  </code></pre>
  
  <p>and it stops working and gives me the same number 50000 times when I comment out printf.</p>