Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class FibonacciNumbers
- {
- static void Main()
- {
- int number = int.Parse(Console.ReadLine());
- int first = 0;
- int second = 1;
- int result = 0;
- if (number == 1 || number == 0)
- {
- Console.WriteLine(first);
- }
- else
- {
- Console.Write("{0} {1} ", first, second);
- for (int i = 2; i < number; i++)
- {
- result = first + second;
- first = second;
- second = result;
- if (i == number - 1)
- {
- Console.Write(result);
- }
- else
- {
- Console.Write(result + " ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement