Created
July 25, 2015 07:11
-
-
Save MladenMladenov/e67af9edff4112abaf1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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