grach

Fibonacci

Jul 20th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Fibonacci
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.  
  15.             int first = 1;
  16.             int second = 1;
  17.  
  18.             for (int i = 0; i < n - 1; i++)
  19.             {
  20.                 int next = first + second;
  21.                 first = second;
  22.                 second = next;   //изместваме ги с 1 настрани
  23.             }
  24.             Console.WriteLine(second);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment