You will throw a die until a 6 is thrown twice in a row.
Besides the currently thrown number, you have to track the previous one.
If both the current and previous numbers are 6s, the program terminates.
using System; class Program/*from w w w . java 2s . co m*/ { static void Main(string[] args) { Random randomNumbers = new Random(); int previous = 0; bool ending; // Throwing until two sixes in a row do { // Actually throwing int thrown = randomNumbers.Next(1, 6 + 1); Console.WriteLine(thrown); // Evaluating ending = thrown == 6 && previous == 6; // Preparing for next round of the loop previous = thrown; } while (!ending); } }