aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk3/lab3/fib.cpp
blob: 75086379a5e37603e25c8eb329d0bce47ac2e5b3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
using namespace std;
int main()
{
  unsigned long long fib1=0, fib2=1, count, temp;
  cout << "How many Fibonacci numbers should be computed? ";
  cin >> count;
  for (int i=1; i<(count+1); i++) {
    temp=fib1+fib2;
    fib1=fib2;
    fib2=temp;
    cout << temp << " ";
    if (i%10==0 && i!=0)
      cout << endl;
  }
  cout << endl;
}