Site Loader
Auckland, New Zealand
Useful to do some arithmetic operations, but helpful for interview Here is the algorithm Here is the code snippet
        public static void FibonnaciSeries(int number)
        {
            int first = 0;
            int second = 1;
            int resultant;
            string series = "0,1";
            if (number == 1)
                series = "0";
            else if (number == 2)
            {
            }
            else
            {
                //Create number till the given value
                for (int i = 0; i < number - 2; i++)
                {
                    //Create 3rd Value (k)
                    resultant = first + second;
                    first = second;
                    second = resultant;
                    series = series + "," + resultant;

                }
            }

            Console.WriteLine("Series : " + series);
        }

Thanks, Karthik KK

Post Author: Karthik kk

Leave a Reply

Your email address will not be published. Required fields are marked *