Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace SandBox
- {
- using System;
- using System.Collections.Generic;
- public class EntryPoint
- {
- public static void Main()
- {
- Queue<long> fiboSeq = new Queue<long>();
- long inputNumber = long.Parse(Console.ReadLine());
- fiboSeq.Enqueue(0);
- fiboSeq.Enqueue(1);
- if (inputNumber == 0)
- {
- Console.WriteLine(0);
- return;
- }
- for (int i = 0; i < inputNumber - 1; i++)
- {
- Stack<long> tempStack = new Stack<long>(fiboSeq);
- long currentNumber = tempStack.Pop();
- long previousNumber = tempStack.Pop();
- fiboSeq.Enqueue(currentNumber + previousNumber);
- }
- // Removes the 0 because the problem description states that
- // the fibojacci sequence should start from 1.
- fiboSeq.Dequeue();
- string output = string.Join(" ", fiboSeq);
- Console.WriteLine(output);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement