DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Aniruddha has posted 40 posts at DZone. View Full User Profile

Finding Nth Fibonacci number in Recursive way - C#

06.02.2012
| 5871 views |
  • submit to reddit
public int FindNthFibonacciNumber(int n)
        {
            if (n == 1 || n == 2) return 1;

            int nthfibonacciNumber = FindNthFibonacciNumber(n - 1) + FindNthFibonacciNumber(n - 2);
            return nthfibonacciNumber;
        }
Finding Nth Fibonacci number in Recursive way - C#