Page 1 of 1

Back again for Fibonacci sequence

Posted: Wed Jul 25, 2012 5:21 pm
by muttley1968
Right i am buildling an app that needs to know all the numbers in Fibonacci sequence as someone put in say 1293 and then it tells them if it is in the sewquence and then also tells them the number before and after weather it is or is not in Fibonacci sequence or not soo any ideas people

Re: Back again for Fibonacci sequence

Posted: Thu Jul 26, 2012 8:06 pm
by DreadNought
This is Fibonacci related.

Not quite what you want, but it's enough, if you ask for even more help you should start with something more simple.

C# - Coded by DreadNought, le me.
Code: Select all

using System;
using System.Collections.Generic;

namespace ProjectEaulaProblem2
{
    class Program
    {
        private static uint[] numbers = new uint[]
                                            {
                                                1, 2, 3, 5, 8, 13, 21, 34, 55, 89
                                            };

        private static List<uint> numbs = new List<uint>(numbers);
        static void Main()
        {
            uint c = numbs[numbs.Count - 1] + numbers[numbs.Count - 2];
            int prevIndex = (numbers.Length - 1);
            uint nextnum = numbers[prevIndex] + numbers[prevIndex - 1];
            Console.WriteLine("Next number = {0}", nextnum);
            Console.WriteLine("Real number = {0}", 55 + 89);
            Console.ReadLine();
        }
    }
}