Skip to content

Instantly share code, notes, and snippets.

@MladenMladenov
Created July 25, 2015 07:11
Show Gist options
  • Save MladenMladenov/e67af9edff4112abaf1a to your computer and use it in GitHub Desktop.
Save MladenMladenov/e67af9edff4112abaf1a to your computer and use it in GitHub Desktop.
using System;
class FibonacciNumbers
{
static void Main()
{
int n = int.Parse(Console.ReadLine());
int a = 0;
int b = 1;
int c;
if (n >= 3)
{
Console.Write(a + " " + b + " ");
for (int i = 0; i < n-2; i++)
{
c = a;
a = b;
b = c + a;
Console.Write(b +" ");
}
Console.WriteLine();
}
else if (n==2)
{
Console.WriteLine(a+" "+b);
}
else if (n==1)
{
Console.WriteLine(a);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment