SHARE
TWEET

Untitled

a guest Jan 25th, 2018 113 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _05M_CalculateSequence
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var n = long.Parse(Console.ReadLine());
  12.  
  13.             var queue = new Queue<long>();
  14.             queue.Enqueue(n);
  15.             int index = 0;
  16.  
  17.             while (queue.Count > 0)
  18.             {
  19.                 index++;
  20.                 long current = queue.Dequeue();
  21.                 Console.Write(current + " ");
  22.                 if (index == 50)
  23.                 {
  24.                     Environment.Exit(0);
  25.                 }
  26.                 queue.Enqueue(current + 1);
  27.                 queue.Enqueue(2 * current + 1);
  28.                 queue.Enqueue(current + 2);
  29.             }
  30.         }
  31.     }
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top