In mathematics, the Fibonacci numbers, commonly denoted Fn form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,
and
for n > 1.
One has F2 = 1. In some books, and particularly in old ones, F0, the “0” is omitted, and the Fibonacci sequence starts with F1 = F2 = 1. The beginning of the Fibonacci sequence is thus:
(wiki)
using System; namespace Program { class Program { static void Main(string[] args) { int i, count, f1 = 0, f2 = 1, f3 = 0; Console.Write("Enter the Limit: "); count = Convert.ToInt16(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(); } } }
Output