Advertisement
Guest User

05.fibonacci

a guest
Oct 12th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace _05._Fibonacci_Numbers
  5. {
  6.     class Program
  7.     {
  8.  
  9.  
  10.         static void Fib()
  11.         {
  12.             int input = int.Parse(Console.ReadLine());
  13.             int a = 1;
  14.             int b = 1;
  15.  
  16.             for (int i = 0; i < input; i++)
  17.             {
  18.                 int temp = a;
  19.                 a = b;
  20.                 b = temp + b;
  21.                 Console.WriteLine(a);
  22.             }
  23.             return;
  24.  
  25.         }
  26.  
  27.  
  28.  
  29.         static void Main(string[] args)
  30.         {
  31.             Fib();
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement