Advertisement
Spocoman

03. Recursive Fibonacci

Jan 23rd, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | None | 0 0
  1. using System;
  2.  
  3. namespace RecursiveFibonacci
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int[] arr = new int[n + 2];
  11.             arr[0] = 1;
  12.  
  13.             for (int i = 0; i < n; i++)
  14.             {
  15.                 arr[i + 2] = arr[i] + arr[i + 1];
  16.             }
  17.             Console.WriteLine(arr[n + 1]);
  18.         }
  19.     }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement