using System;
using System.Collections.Generic;
public class FairRandom {
private int lastNumber = 3; // we always need to know the last number generated
// so it's a private field
private Random rnd;
public FairRandom(int seed){
rnd = new Random(seed);
}
// we would also like to reuse the same Random object
public int Next() {
int num;
if (lastNumber == 6) {
num = rnd.Next(1,3);
else if (lastNumber == 1) {
num = rnd.Next(5,7);
else {
num = rnd.Next(1,7);
lastNumber = num;
return num;
public class Program
{
public static void Main()
FairRandom rnd = new FairRandom(90);
for (int i=0;i<100;i++)
Console.WriteLine(rnd.Next());