Advertisement
Guest User

Sequence calculation

a guest
Jul 14th, 2015
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. namespace CalculateSequence
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.  
  6.     public class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int start = int.Parse(Console.ReadLine());
  11.             Queue<int> queue = new Queue<int>();
  12.             Console.Write(start + " ");
  13.             for (int i = 0; i <= 50; i++)
  14.             {
  15.                 queue.Enqueue(start + 1);
  16.                 queue.Enqueue((2 * start) + 1);
  17.                 queue.Enqueue(start + 2);
  18.  
  19.                 start = queue.Dequeue();
  20.                 Console.Write(start);
  21.                 if (i != 50)
  22.                 {
  23.                     Console.Write(" ");
  24.                 }
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement