Fibonacci series

Rajesh_Kumar
Posted by Rajesh_Kumar under C# category on | Points: 40 | Views : 685
int[] arr1 = { 1, 2, 100 }; // Take Array with 3 elements

int n1, n2; //Take 2 variables
n1 = n2 = arr1[0];
Console.WriteLine(n1);

while (n2 < arr1[2])
{
Console.WriteLine(n2);
n2 += n1;
n1 = n2 - n1;
}

Console.ReadLine();

Comments or Responses

Login to post response