Blame | Last modification | View Log | RSS feed
<p>
The point here is that you often will need to avoid some values within the random range. For example, if you generate a random quadratic polynomial \(ax^2+bx+c), you don't want \a to be zero, for this is a degenerate case.
In this case, you can generate two random integers, one from 1 to \n, the other randomly takes 1 or -1. And the multiplication of the two gives a random integer in the range [-\n ; \n] that is always non-zero.
Generated by GNU Enscript 1.6.5.90.