using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplicationfibonacciseries
{
class Program
{
static void Main(string[] args)
{
int a = 0, b = 1, c, n;
Console.WriteLine("Enter a number");
n = int.Parse(Console.ReadLine());
Console.WriteLine("Fibonic series is:");
Console.WriteLine("" + a);
Console.WriteLine("" + b);
for (int i = 2; i <= n; i++)
{
c = a + b;
a = b;
b = c;
Console.WriteLine(c);
Console.ReadLine();
}
}
}
}
Output:

using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplicationfibonacciseries
{
class Program
{
static void Main(string[] args)
{
int a = 0, b = 1, c, n;
Console.WriteLine("Enter a number");
n = int.Parse(Console.ReadLine());
Console.WriteLine("Fibonic series is:");
Console.WriteLine("" + a);
Console.WriteLine("" + b);
for (int i = 2; i <= n; i++)
{
c = a + b;
a = b;
b = c;
Console.WriteLine(c);
Console.ReadLine();
}
}
}
}
Output:
No comments:
Post a Comment