Advertisement
SSkrev

Fibonacci Numbers

Mar 17th, 2014
800
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.45 KB | None | 0 0
  1. using System;
  2.  
  3. class FibonacciNumbers
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("n=");
  8.         int n = int.Parse(Console.ReadLine());
  9.         int fiboTemA = 0;
  10.         int fiboTempB = 1;
  11.         for (int i = 0; i < n; i++)
  12.         {
  13.             Console.Write(fiboTemA + " ");      
  14.             int temp = fiboTemA;
  15.             fiboTemA = fiboTempB;
  16.             fiboTempB = temp + fiboTempB;                  
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement