Mathematicaly, that's a random number generator:
x 0 = given, x n+1 = P 1 x n + P 2 (mod N) n = 0,1,2,...
The parameters P 1, P 2, and N determine the characteristics of the random number generator, and the choice of x 0 (the seed ) determines the particular sequence of random numbers that is generated. In your case N is 101.
2eza ma beddak twajje3 rasak, try this:
Quote:
import java.util.Random;
class rndGen
{
static Random wheel = new Random();
public static void main(String[] args)
{
for(int i=0; i<300; i++)
{
// generate an int in range 0..100 inclusive.
int low = 0;
int high = 100;
int m = wheel.nextInt( high - low + 1 ) + low;
System.out.print( m + " ");
}
}
}
|