Wednesday, May 19, 2010

Fibonacci Series in c#.net

public void Fibonacci(int i)
{
int j = 0;
int k = 1;
int Temp;
int n = 0;
for (int m = 0; m <= i; m++)
{
Temp = j + k;
Console.Write(j);
j = k;
k = Temp;

}
////Using While Loop
//while (n < i)
//{
// Console.Write(j);
// Temp = j + k;
// j = k;
// k = Temp;
// n++;
//}
Console.WriteLine();
}

No comments:

Post a Comment