Fibonacci series is a pattern in which digits are shown in a manner that it adds the last two digit from the series ie..
0 1 1 2 3 5 8......... n..
Here, the first no is 0 and the second no is 1 so the third number must be 0+1, and the fourth number must be Sum of Second and Third.. ie 1+1, like wise we must create it for the Entire Series....
----------------------------------------------
using System;
namespace MyFibonacciApp
{
class _FibonacciSeries
{
static void Main(string[] args)
{
int j = 0;
int k = 0;
int l = 1;
for(int i = 0; i <10;i++)
{
Console.Write("{0} ", k);
j = l;
l = k;
k = l + j;
}
}
}
}
----------------------------------
2 comments:
it is very nice.less coding and easy to understand.
it is short and easier thanks.....!
Post a Comment