Advertisement
dimov

Untitled

Jan 8th, 2013
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class Recursion
  5. {
  6.     static void Main()
  7.     {
  8.         Console.WriteLine("Please input n");
  9.         int n = int.Parse(Console.ReadLine());
  10.         Console.WriteLine(Fib(n));
  11.  
  12.     }
  13.  
  14.     static long Fib(int n)
  15.     {
  16.         if (n <2)
  17.         {
  18.             if (n == 1)
  19.             {
  20.                 return 1;
  21.             }
  22.             if (n==0)
  23.             {
  24.                 return 0;
  25.             }
  26.            
  27.         }
  28.         return Fib(n - 1) + Fib(n - 2);
  29.     }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement