Advertisement
Guest User

Untitled

a guest
Jan 25th, 2018
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement