Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApplication9
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int a = 0;
  11.             int b = 1;
  12.             int c = 0;
  13.            
  14.             if ( n == 1 || n == 0 )
  15.             {
  16.                 Console.WriteLine(a);
  17.             }
  18.             else
  19.             {
  20.                 Console.Write("{0}, {1}", a, b);
  21.  
  22.                 for (int i = 0; i < n - 2; i++)
  23.                 {
  24.                     c = a + b;
  25.                     Console.Write(", " + c);
  26.                     a = b;
  27.                     b = c;
  28.                 }
  29.             }
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement