Program to generate Fibonacci series in C Sharp/C#

By | April 27, 2011

Hi,

Here is a simple program to generate Fibonacci series using C Sharp /C#. It will generate Fibonacci numbers < 100. [csharp] class MainClass { public static void Main() { int oldNum = 1; int presentNum = 1; int nextNum; System.Console.Write(presentNum + ","); while (presentNum < 100) { System.Console.Write(presentNum + ","); nextNum = presentNum + oldNum; oldNum = presentNum; presentNum = nextNum; } } } [/csharp] 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *