hamzajaved

Print N number of Fibonacci series

Oct 8th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1.  class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             int N,a=-1,b=1,c;
  6.             Console.WriteLine("Enter the Number of Series to print");
  7.             N = Convert.ToInt16(Console.ReadLine());
  8.  
  9.             for(int i=1; i<= N; i++)
  10.             {
  11.                 c = a + b;
  12.                 Console.Write(" " + c);
  13.                 a = b;
  14.                 b = c;
  15.             }
  16.  
  17.             Console.ReadLine();
  18.         }
  19.     }
Add Comment
Please, Sign In to add comment