Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CalculateSequanceWithQueue
- {
- class QueueSeqTest
- {
- static void Main(string[] args)
- {
- long startNumber = long.Parse(Console.ReadLine());
- Queue<long> sequance = new Queue<long>();
- sequance.Enqueue(startNumber);
- StringBuilder result = new StringBuilder();
- int counter = 0;
- while (counter != 50)
- {
- long currNum = sequance.Dequeue();
- result.Append(currNum + " ");
- sequance.Enqueue(currNum + 1);
- sequance.Enqueue((currNum * 2) + 1);
- sequance.Enqueue(currNum + 2);
- counter++;
- }
- Console.WriteLine(result.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement