Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - using System;
 - namespace Quick
 - {
 - class Program
 - {
 - static void Main(string[] args)
 - {
 - var rand = new Random();
 - var successes = 0;
 - var failures = 0;
 - var highestFailure = 0;
 - for (int i = 0; i < 10000; i++)
 - {
 - int total = 0;
 - int peak = 0;
 - do
 - {
 - total += rand.Next(1, 20);
 - if (total > peak)
 - {
 - peak = total;
 - }
 - total -= 4;
 - if (total >= 10000000)
 - {
 - successes++;
 - break;
 - }
 - }
 - while (total > 0);
 - if (total <= 0)
 - {
 - if (peak > highestFailure)
 - {
 - highestFailure = peak;
 - }
 - failures++;
 - }
 - }
 - Console.WriteLine($"successes:{successes}");
 - Console.WriteLine($"failures:{failures}");
 - Console.WriteLine($"highest failure:{highestFailure}");
 - Console.Read();
 - }
 - }
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment