Before starting the code you have to know about the Fibonacci series.
The Fibonacci Series is the series that is the set of numbers where each number is the sum of two or more preceding numbers.
For eg:- 5 number Fibonacci Series is,
Like this, a 10 number Fibonacci Series is:
0 + 1 = 1
1 + 1 = 2
1 + 2 = 3
2 + 3 = 5
3 + 5 = 8
5 + 8 =13
8 + 13 =21
13 + 21 =34
21 + 34 =55
34 + 55 =89
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Even_Fibonacci_numbers {
class Program {
static void Main(string[] args) {
int term, a = 1, b = 2, tn;
Console.Write("Enter number to print time of fabonacci series : ");
term = int.Parse(Console.ReadLine());
Console.Write(a + "," + b + ",");
for (int i = 0; i < term - 2; i++) {
tn = a + b;
Console.Write(tn + ",");
a = b;
b = tn;
}
Console.Read();
}
}
}
This algorithm is printed as a user-long sum of two preceding numbers 'Fibonacci Series' number.
Output