View Single Post
Old 12-18-2011   #2
Google

 
Google's Avatar
 
Last Online: 05-30-2013
Join Date: Jan 2008
Posts: 1,788
Thanks: 10,018
Thanked 1,100 Times in 651 Posts
Groans: 1
Groaned at 6 Times in 6 Posts
Default

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 + " ");
}
}
}
__________________

Google is offline   Reply With Quote