Fibonacci series

Pages: 12
There is no limit of the improvment.:) Thus the next release is



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <cstdlib>

int main()
{
   unsigned fibonacci[] = { 0, 1 };

   std::cout << "Fibonacci seria less than 100: " 
                 << fibonacci[0] << ' '
                 << fibonacci[1];

   while ( ( fibonacci[1] += fibonacci[0] ) <= 100 ) 
   {
      std::cout << ' ' << fibonacci[1];

      fibonacci[0] = fibonacci[1] - fibonacci[0];
   }

   std::cout << std::endl;

   std::system( "PAUSE" );

   return 0;
} 
Last edited on
Topic archived. No new replies allowed.
Pages: 12