The Fibonacci numbers may be defined by the recurrence relation.
Fn = F(n-1) + F(n-2)
The first 10 Fibonacci numbers Fn are:
n = | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|---|---|---|---|---|---|---|---|---|---|
Fn = | 0 | 1 | 1 | 2 | 3 | 5 | 8 | 13 | 21 | 34 |
- Added sequence calculation using recursive function;
- Added the header file cmath;
- Fixed system("CLS") to system("clear || cls");
- Source code organized by scope.
g++ FibonacciSequence.cpp -o FibonacciSequence
./FibonacciSequence