saimun1

Fibonacci C#

Jul 21st, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 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 test
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int f0 = 0;
  15.             int f1 = 1;
  16.             int fN = 0;
  17.             int n = int.Parse(Console.ReadLine());
  18.             do
  19.             {
  20.                 fN = f0 + f1;
  21.                 f0 = f1;
  22.                 f1 = fN;
  23.                 ;
  24.  
  25.                 n--;
  26.  
  27.             }
  28.             while (n > 0);
  29.  
  30.             Console.WriteLine(f1);
  31.             Console.ReadLine();
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment