Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Numerics;
- class FibonacciNumbers
- {
- static void Main()
- {
- int n = Int32.Parse(Console.ReadLine());
- int[] fibonacci = new int[n];
- if(n==1)
- {
- Console.WriteLine(0);
- }
- else
- {
- fibonacci[0] = 0;
- fibonacci[1] = 1;
- int first = 0;
- int second = 1;
- int third = 0;
- for (int i = 2; i < n; i++)
- {
- third = first + second;
- fibonacci[i] = third;
- first = second;
- second = third;
- }
- for (int i = 0; i < fibonacci.Length; i++)
- {
- Console.Write(fibonacci[i]+" ");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement