Advertisement
remote87

Fibonacci Numbers

Aug 28th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Numerics;
  7.  
  8. namespace _10.FibonacciNumbers
  9. {
  10.     class FibonacciNumbers
  11.     {
  12.         static void Main()
  13.         {
  14.             Console.WriteLine("Enter a number N for range: ");
  15.             BigInteger n = BigInteger.Parse(Console.ReadLine());
  16.             BigInteger firstNum = 0;
  17.             BigInteger secondNum = 1;
  18.             BigInteger thirdNum = 1;
  19.             for (int i = 0; i < n; i++)
  20.             {
  21.                 thirdNum = secondNum;
  22.                 secondNum = firstNum + secondNum;
  23.                 firstNum = thirdNum;
  24.                 Console.Write(firstNum + " ");
  25.             }
  26.             Console.ReadLine();
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement