Advertisement
Guest User

Untitled

a guest
Mar 19th, 2020
934
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. class Program
  4. {
  5. static void Main()
  6. {
  7. int positionInFibonacciSequence = int.Parse(Console.ReadLine());
  8. int[] fibonacciSequence = new int[50];
  9.  
  10. fibonacciSequence[0] = 1;
  11. fibonacciSequence[1] = 1;
  12.  
  13. if (positionInFibonacciSequence > 2)
  14. {
  15. for (int i = 2; i < positionInFibonacciSequence; i++)
  16. {
  17. fibonacciSequence[i] = fibonacciSequence[i - 1] + fibonacciSequence[i - 2];
  18. }
  19. }
  20. Console.WriteLine(fibonacciSequence[positionInFibonacciSequence - 1]);
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement