GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

i am writing a code of fabbonacci series

asked Feb 24, 2017 by Shivam Monga

1 Answer

 

public static void fab(int num)
        {

            int[] array = new int[num];

            array[0] = 0;
            array[1] = 1;

            for (int i = 0; i < num; i++)
            {
                if (i == 0)
                    Console.WriteLine(array[0]);
                else if (i == 1)
                    Console.WriteLine(array[1]);
                else
                {
                    array[i] = array[i - 2] + array[i - 1];
                    Console.WriteLine(array[i]);
                }
            }
        }

 

answered Feb 24, 2017 by Shrikaant
...