using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Apps
{
class FibanocciServiesClass
{
private int temp;
public void Fibanocci(int j)
{
int a = 1;
int b = 0;
if (j == 0)
Console.WriteLine(0);
else
{
Console.Write(b+"\t");
Console.Write(a + "\t");
while (temp < j)
{
temp = a + b;
b = a;
a = temp;
if (temp < j)
Console.Write(temp + "\t");
}
}
}
}
class FibanocciSeries
{
public static void Main()
{
Console.WriteLine("Enter a number");
int i = Int32.Parse(Console.ReadLine());
FibanocciServiesClass s1 = new FibanocciServiesClass();
s1.Fibanocci(i);
}
}
}
No comments:
Post a Comment