Enter the Limit : 10 0 1 1 2 3 5 8 13 21 34 55 89 144
Users Online
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Latest Articles
Articles Hierarchy
Fibonacci Series Program in C#
Fibonacci Series Program in C#
This is a C# Program to generate fibonacci series.
This C# Program generates Fibonacci series.
The numbers that precedes the series are 0 and 1. The next number is found by adding up the two numbers before it.
Here is source code of the C# program which generates a Fibonacci series.The C# program is successfully compiled and executed with Microsoft Visual Studio.The program output is also shown below.
/* * C# Program to Generate Fibonacci Series */ using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace fibonaci { class Program { static void Main(string[] args) { int i, count, f1 = 0, f2 = 1, f3 = 0; Console.Write("Enter the Limit : "); count = int.Parse(Console.ReadLine()); Console.WriteLine(f1); Console.WriteLine(f2); for (i = 0; i <= count; i++) { f3 = f1 + f2; Console.WriteLine(f3); f1 = f2; f2 = f3; } Console.ReadLine(); } } }
In this C# program, we are reading the limit to generate the Fibonacci series using ‘count’ variable. The numbers that precede the series are 0 and 1. The next number is found by adding up the two numbers before it. Using for loop generate Fibonacci series.
Initialize the value of ‘i’ variable as 0 and check the condition that the value of ‘i’ variable is less than or equal to the value of ‘count’ variable. Compute the summation of the value of ‘f1’ variable with the value of ‘f2’ variable. Print the Fibonacci series of the value.