29 July 2013

fibonacci series between 1 to 50 in c#

public class FIBONACCI
{

public static void Main()
{

int oldNumber = 1;
int currentNumber = 1;

int nextNumber;

System.Console.Write(currentNumber + " ");

while (currentNumber < 50)
{
System.Console.Write(currentNumber + " ");

nextNumber = currentNumber + oldNumber;

oldNumber = currentNumber;
currentNumber = nextNumber;
}

}

}

No comments:

Post a Comment