using System;
class abc
{
int a = 0, b = 1, limit;
public void fun()
{
Console.WriteLine("Enter the limit upto which you want to print fibonacci series: ");
limit = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("fibonacci series is : ");
Console.WriteLine(a);
while (b < limit)
{
Console.WriteLine(b);
b = b + a;
a = b - a;
}
Console.ReadKey();
}
}
class fibonacci
{
public static void Main(string[] args)
{
abc a1 = new abc();
a1.fun();
}
}
Output
class abc
{
int a = 0, b = 1, limit;
public void fun()
{
Console.WriteLine("Enter the limit upto which you want to print fibonacci series: ");
limit = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("fibonacci series is : ");
Console.WriteLine(a);
while (b < limit)
{
Console.WriteLine(b);
b = b + a;
a = b - a;
}
Console.ReadKey();
}
}
class fibonacci
{
public static void Main(string[] args)
{
abc a1 = new abc();
a1.fun();
}
}
Output
No comments :
Post a Comment