Created
May 19, 2016 20:42
-
-
Save vdonchev/a05c074fa4f54b6b2d84eca9e74a7527 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace _05.CalculateSequenceWithQueue | |
| { | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Numerics; | |
| public static class CalculateSequenceWithQueue | |
| { | |
| public static void Main() | |
| { | |
| var queue = new Queue<BigInteger>(); | |
| queue.Enqueue(BigInteger.Parse(Console.ReadLine())); | |
| var steps = 0; | |
| while (queue.Count > 0 && steps++ < 50) | |
| { | |
| var num = queue.Dequeue(); | |
| Console.Write($"{num} "); | |
| queue.Enqueue(num + 1); | |
| queue.Enqueue((2 * num) + 1); | |
| queue.Enqueue(num + 2); | |
| } | |
| Console.WriteLine(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment