Determine Fibanocci Series
using System;
class FibnocciSeries
{
public static void Main(String[] args)
{
int a=-1,b=1,c,i,limit;
Console.WriteLine("Enter the limit of the series:");
limit=Convert.ToInt32(Console.ReadLine());
for(c=1;c<=limit;c++)
{
i=a+b;
Console.Write(i+" ");
a=b;
b=i;
}
}
}
output:class FibnocciSeries
{
public static void Main(String[] args)
{
int a=-1,b=1,c,i,limit;
Console.WriteLine("Enter the limit of the series:");
limit=Convert.ToInt32(Console.ReadLine());
for(c=1;c<=limit;c++)
{
i=a+b;
Console.Write(i+" ");
a=b;
b=i;
}
}
}
No comments:
Post a Comment