Tuesday, 27 November 2012

Fibonacci Series

using System;
using System.Collections.Generic;
using System.Text;

namespace fibonacci_series
{
class fibo
{
static void Main(string[] args)
{
int f1 = 0, f2 = 1, n,f3,i;
Console.WriteLine("\tFIBONACCI SERIES");
Console.WriteLine("\t****************");
Console.WriteLine("Enter the number");
n = int.Parse(Console.ReadLine());
Console.WriteLine("The Series is");
Console.WriteLine("{0}\n{1}", f1, f2);
for (i = 1; i <= n; i++)
{
f3 = f1 + f2;
f1 = f2;
f2 = f3;
Console.WriteLine("{0}", f3);
}


}
}
}

No comments:

Post a Comment