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....
Here is the Program to show the first ten digits in Fibonacci Series in C#...
----------------------------------------------
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;
}
}
}
}
----------------------------------
No comments:
Post a Comment