elena1234

Calculate Fibonacci Series

Dec 4th, 2021
1,353
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace Fibonacci
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int len = int.Parse(Console.ReadLine());
  10.             int a = 0, b = 1, c = 0;
  11.             Console.Write("{0} {1}", a, b);
  12.  
  13.             for (int i = 2; i < len; i++)
  14.             {
  15.                 c = a + b;
  16.                 Console.Write(" {0}", c);
  17.                 a = b;
  18.                 b = c;
  19.             }
  20.         }
  21.     }
  22. }
  23.  
RAW Paste Data