Fibonacci Series

// Fibonacci Series.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream"
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
       const unsigned long limit = 4294957295;
       unsigned long next = 0;
       unsigned long last = 1;
       long sum;
       cout << " \n\n This program will print the Fibonacci series: \n\n";
       while(next < limit/2)
       {
             cout << last << " " ;
             sum = next + last;
             next = last;
             last = sum;
       }
       system("pause");
       return 0;
}



Share on Google Plus