- Get link
- X
- Other Apps
By using the following example we can print the Fibonacci Series
For Example to find the Fibonacci Series, firstly set the first two number in the series as 0 and 1.
What is Fibonacci Series?
In case of Fibonacci series, Next number is the sum of previous two numbers like 0,1,1,2,3,5,8 etc. Mainly the first two numbers of fibonacci series are 0 and 1.
Click on Visual Studio it is an IDE for the .Net developer's:
After this you can write your Project name like Fibonacci Series for our better understanding purpose:
After writing your project name then you should select here the template for the console application then only you can click on the next button to enter your code editor:
With that you can write the logic in Code Editor We can write the logic what we want based on our requirement like below:
Here We are intialising the values what we need like int a ,b etc.
using System;
namespace Fibonacci Series
{
class Program
{
static void Main(string[] args)
{
int a = 0, b = 1, c, i, n;
n = 7;
Console.WriteLine("Fibonacci Series:");
Console.Write(a + " " + b + " ");
for(i=2;i<n;++i)
{
c = a + b;
Console.Write(c + " ");
a = b;
b = c;
}
Console.ReadLine();
}
}
}
Finally the output of the above program is:
Fibonacci Series:
0 1 1 2 3 5 8
The program will be looking like below in the visual studio:
The Output will be displayed in command prompt:
- Get link
- X
- Other Apps





Comments
Post a Comment