Write a c# program to print fibonacci series without using recursion and using recursion.



Without recursion
using System;

namespace FibonacciSeries
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 10;
            int a = 0;
            int b = 1;
            Console.WriteLine("Fibonacci series without recursion:");
            for (int i = 0; i < n; i++)
            {
                int c = a + b;
                Console.Write("{0} ", c);
                a = b;
                b = c;
            }
            Console.ReadKey();
        }
    }
}
With recursion
using System;

namespace FibonacciSeries
{
    class Program
    {
        static int Fibonacci(int n)
        {
            if (n == 0)
            {
                return 0;
            }
            else if (n == 1)
            {
                return 1;
            }
            else
            {
                return Fibonacci(n - 1) + Fibonacci(n - 2);
            }
        }

        static void Main(string[] args)
        {
            int n = 10;
            Console.WriteLine("Fibonacci series with recursion:");
            for (int i = 0; i < n; i++)
            {
                int f = Fibonacci(i);
                Console.Write("{0} ", f);
            }
            Console.ReadKey();
        }
    }
}
Write a c# program to print fibonacci series without using recursion and using recursion. Write a c# program to print fibonacci series without using recursion and using recursion. Reviewed by Bhaumik Patel on 10:54 PM Rating: 5