Advertisement
VasilKotsev

Fibonacci sequence

Jan 19th, 2019
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. namespace SandBox
  2. {
  3.     using System;
  4.  
  5.     public class EntryPoint
  6.     {
  7.         public static void Main()
  8.         {
  9.             int numberOfDesiredElementsFromSequence = int.Parse(Console.ReadLine());
  10.  
  11.             long f0Temp = 1L;
  12.             long f1Temp = 1L;
  13.  
  14.             Console.Write($"{f0Temp} {f1Temp} ");
  15.  
  16.             for (int i = 2; i < numberOfDesiredElementsFromSequence; i++)
  17.             {
  18.                 long tempNumber = f1Temp;
  19.                 f1Temp = f1Temp + f0Temp;
  20.                 f0Temp = tempNumber;
  21.  
  22.                 Console.Write($"{f1Temp} ");
  23.             }
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement