Esempio n. 1
0
        private static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("Get which position in the Fibonacci sequence (Type 'X' to finish) : ");
                var positionString = Console.ReadLine();

                if (positionString == null || positionString.ToUpper() == "X")
                {
                    break;
                }

                var seqNumber = FibonacciGenerator.GetNumberInNPositonOfSequence(positionString);

                if (seqNumber == -1)
                {
                    Console.WriteLine("The value '{0}' you entered was invalid!", positionString);
                }
                else
                {
                    Console.WriteLine("The {0} number in the Fibonacci Sequence is : = {1}", positionString, seqNumber);
                }
            }
        }
Esempio n. 2
0
        public void GivenANumberWhenNumberGenerateThenItMatchesExpected(string input, Int64 expected)
        {
            var result = FibonacciGenerator.GetNumberInNPositonOfSequence(input);

            Assert.AreEqual(expected, result);
        }