A simple resolution to a common algorithm excercise.
Print to the console the "FIBONACCI SEQUENCE", a sequence of numbers beginning with 0 and 1, beeing the next one the sum of the two predecessors. The number passed as parameter is the amount of iteractions the list should have.
Example: for a list that should have 8 iteractions,
0
1
1
2
3
5
8
13
21
34
55
We use two examples of solution:
- one by making a for loop and making the sum of the two predecessor numbers;
- other by making a recursive loop, making the sum by calling the same function passing the two predecessor numbers.
Check the code to verify my answer. This are made for academic and training purposes only.