Fibonacci Series Program in C#
Advertisements
Fibonacci Series Program in C#
Fibonacci Series add two previous term and get next term its first two terms are 0 and 1. Fibonacci series are; 0 1 1 2 3 5 8 13.....
Fibonacci Series Program in C#
using System; namespace fibonaci { class Program { static void Main(string[] args) { int i, count, term1 = 0, term2 = 1, term3 = 0; Console.Write("Enter the Limit: "); count = int.Parse(Console.ReadLine()); Console.WriteLine(term1); Console.WriteLine(term2); for (i=0; i<=count; i++) { term3 = term1 + term2; Console.WriteLine(term3); term1 = term2; term2 = term3; } Console.ReadLine(); } } }
Output
Enter the Limit: 34 0 1 1 2 3 5 8 13 21 34
Output
Enter the Limit: 13 0 1 1 2 3 5 8 13
Google Advertisment