Exemple #1
0
        static void Main(string[] args)
        {
            FiboSeed seeds = new FiboSeed(3, 3);

            FibonacciSeries.fibo(seeds, 7).ForEach(s => Console.WriteLine(s));
            Console.Read();
        }
Exemple #2
0
        public static List <int> fibo(FiboSeed seeds, int iterations)
        {
            Console.WriteLine("Fibo initial seeds: (lower) = " + seeds.LowerSeed + " (upper) = " + seeds.UpperSeed);
            var fiboSeries = new List <int>();

            fiboSeries.Add(seeds.LowerSeed);

            int nextSeed    = 0;
            int prevSeed    = seeds.LowerSeed;
            int holdingSeed = seeds.UpperSeed;

            for (int i = 0; i < iterations; i++)
            {
                nextSeed = prevSeed + holdingSeed;

                fiboSeries.Add(nextSeed);

                // reassignments
                holdingSeed = prevSeed;
                prevSeed    = nextSeed;
            }

            return(fiboSeries);
        }