Fibonacci Series code in c# without recursion.
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
Fibonacci
{
class
Program
{
static void Main(string[] args)
{
Console.WriteLine(".........Fibonacci
Series......");
int i = 0; int j = 1;
int k = 1;
Console.Write("Enter
the no:");
int m =Convert.ToInt32(Console.ReadLine());
Console.Write("series
are:");
int n;
Console.Write("
{0} {1} ", i,j);
for (n = 0; n <= m;n++ )
{
k = i + j;
i = j;
j = k;
Console.Write("
{0} ",k);
}
Console.ReadKey();
}
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.