Advertisement
dragonbs

Recursive Fibonacci

Feb 12th, 2023
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.24 KB | None | 0 0
  1. int input = int.Parse(Console.ReadLine());
  2. Console.WriteLine(GetFibonacci(input));
  3.  
  4.     static int GetFibonacci(int n)
  5. {
  6.     if (n == 2 || n == 1) return 1;
  7.     int number = GetFibonacci(n - 1) + GetFibonacci(n - 2);
  8.     return number;
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement