Advertisement
Guest User

Untitled

a guest
May 25th, 2016
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 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 Fibonacci
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int number = int.Parse(Console.ReadLine());
  14.  
  15.             Console.WriteLine(Fib(number));
  16.         }
  17.  
  18.         static long Fib(int n)
  19.         {
  20.             if (n < 2)
  21.             {
  22.                 return 1L;
  23.             }
  24.  
  25.             return Fib(n - 1) + Fib(n - 2);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement