static void Main(string[] args)
{
int prev=0, next=1, sum=0;
Console.WriteLine("Enter No. of terms you want in Series");
int n = Convert.ToInt32(Console.ReadLine());
Console.Write(prev+" ");
Console.Write(next);
for(int i=0;i<n-1;i++)
{
sum = prev + next;
prev = next;
next = sum;
Console.Write(" "+next);
}
Console.ReadLine();
}
{
int prev=0, next=1, sum=0;
Console.WriteLine("Enter No. of terms you want in Series");
int n = Convert.ToInt32(Console.ReadLine());
Console.Write(prev+" ");
Console.Write(next);
for(int i=0;i<n-1;i++)
{
sum = prev + next;
prev = next;
next = sum;
Console.Write(" "+next);
}
Console.ReadLine();
}
No comments:
Post a Comment