Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class Recursion
- {
- static void Main()
- {
- Console.WriteLine("Please input n");
- int n = int.Parse(Console.ReadLine());
- Console.WriteLine(Fib(n));
- }
- static long Fib(int n)
- {
- if (n <2)
- {
- if (n == 1)
- {
- return 1;
- }
- if (n==0)
- {
- return 0;
- }
- }
- return Fib(n - 1) + Fib(n - 2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement