C# Fibonacci Sequence

C# Program to Generate Fibonacci Series.

using System;

public class Program
{
    public static void Main()
    {
        Console.WriteLine("Fibonacci numbers");
        for (int i = 0; i < 15; i++)
        {
            Console.WriteLine(Fibonacci(i));
        }
    }

    public static int Fibonacci(int n)
    {
        int a = 0;
        int b = 1;
        // In N steps compute Fibonacci sequence iteratively.
        for (int i = 0; i < n; i++)
        {
            int temp = a;
            a = b;
            b = temp + b;
        }

        return a;
    }
}
DEMO
C# Fibonacci Sequence C# Fibonacci Sequence Reviewed by Bhaumik Patel on 5:22 AM Rating: 5