Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- class Program
- {
- static void Main(string[] args)
- {
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- int numberOfCombination = int.Parse(Console.ReadLine());
- int counter = 0;
- if (numberOfCombination >= 1 && numberOfCombination <= 13_983_816)
- {
- for (int firstNumber = 1; firstNumber <= 44; firstNumber++)
- {
- for (int secondNumber = firstNumber + 1; secondNumber <= 45; secondNumber++)
- {
- for (int thirdNumber = secondNumber + 1; thirdNumber <= 46; thirdNumber++)
- {
- for (int fourthNumber = thirdNumber + 1; fourthNumber <= 47; fourthNumber++)
- {
- for (int fifthNumber = fourthNumber + 1; fifthNumber <= 48; fifthNumber++)
- {
- for (int sixthNumber = fifthNumber + 1; sixthNumber <= 49; sixthNumber++)
- {
- string combination = firstNumber.ToString() + "-" + secondNumber.ToString() + "-" + thirdNumber.ToString() + "-" + fourthNumber.ToString() + "-" + fifthNumber.ToString() + "-" + sixthNumber.ToString();
- counter++;
- if (numberOfCombination == counter)
- {
- Console.WriteLine($"Lottery combination: {combination}");
- Console.WriteLine("Your chance to win is 1/13 983 816, so good luck! :)");
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- string elapsedTime = String.Format("{0:00} seconds.{1:00} milliseconds", ts.Seconds, ts.Milliseconds / 10);
- Console.WriteLine($"Execution time: {elapsedTime}");
- return;
- }
- }
- }
- }
- }
- }
- }
- }
- else
- {
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- string elapsedTime = String.Format("{0:00} seconds.{1:00} milliseconds", ts.Seconds, ts.Milliseconds / 10);
- Console.WriteLine("Input a valid number between 1-13_983_816 for the combination!");
- Console.WriteLine($"Execution time: {elapsedTime}");
- }
- }
- }
Add Comment
Please, Sign In to add comment