Generate at least 20 random numbers within the range of 1 to 900 using linear congruent method. Xi = (aXo + C) mod m using a = 87, c = 29 and Xo = 19
Using the linear congruence Xi = (aXo + C) mod m, we want to generate random numbers 1 to 900, so we can take m = 901 so that maximum remainder can be 900. (using a = 87, c = 29 and Xo = 19)
X1 = (87*19 + 29) mod 901 or X1 = 781
X2 = (87*781 + 29) mod 901 or X2 =
401
X3 = (87*401 + 29) mod 901 or X3 =
678
X4 = (87*678 + 29) mod 901 or X3 =
450
X5 = (87*450 + 29) mod 901 or X3 =
436 and so on.
The first 20 generated random numbers are:
781, 401, 678, 450, 436, 119, 471, 461, 492, 486, 865,
501, 368, 510, 250, 155, 900, 843, 389, 535.
Get Answers For Free
Most questions answered within 1 hours.