Advertisement
EmoRz

Fibonacci

Aug 22nd, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.30 KB | None | 0 0
  1. using System;          
  2.            
  3. public class Program           
  4. {          
  5.     public static void Main()      
  6.     {      
  7.         var n = int.Parse(Console.ReadLine()); 
  8.         var f1 = 1;
  9.         var f2 = 1;
  10.         for(int i = 1; i <= n - 1; i++)
  11.         {  
  12.             var temp = f1+f2;
  13.             f1 = f2;
  14.             f2 = temp;
  15.         }  
  16.         Console.WriteLine(f2); 
  17.            
  18.     }      
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement