Introduction :
In case of fibonacci series, next number is the sum of previous two numbers for example 0, 1, 1, 2, 3, 5, 8, 13, 21 etc. The first two numbers of fibonacci series are 0 and 1.
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 Fibonancy_series { class Program { public static int fibonancy(int n) { int a = 0; int b = 1; for (int i = 0; i < n; i++) { int temp = a; a = b; b = temp + b; } return a; } static void Main() { for (int i = 0; i < 15; i++) { Console.WriteLine(fibonancy(i)); Console.ReadLine(); } } }
OutPut of Program :
Learn Recommended posts :
C# Program to find sum of elements in a given array
C# program to find maximum and minimum element in array
How do you reverse a string in C#
C# program to Check String is palindrom or not
How to print Pyramid Pattern in C#
How do you count the no of digits or character in C#
Factorial Number Program in C# using Recursion
Convert string to char array in C#
Finding the biggest of three numbers in C#
C# Program to Check Whether the Entered Number is an Armstrong Number or Not