Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Fibonacci numbers - 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
- using System;
- class Program
- {
- static long Fib(int n)
- {
- if (n <= 2)
- {
- return 1;
- }
- return Fib(n - 1) + Fib(n - 2);
- }
- static void Main()
- {
- int element = 10;
- long result = Fib(element);
- Console.WriteLine("The {0} Fibonacci number is {1}", element, result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement