The Fibonacci Series is a numeric series starting with the integers 0 and 1. In this series, the next integer is determined by summing the previous two. This gives us:
0, 1, 1, 2, 3, 5, 8, 13, ... Note When asking for the nth number in series presume starting at zero.
fibonacci(0) == 0, fibonacci(1) == 1, fibonacci(2) == 1, etc.
The Lucas Numbers are a related series of integers that start with the values 2 and 1 rather than 0 and 1. The resulting series looks like this:
2, 1, 3, 4, 7, 11, 18, 29, ...
-
we Created a function called fibonacci. had one parameter n. The function should returned the nth value in the fibonacci series.
-
then, we added a new function lucas that returned the nth value in the lucas numbers Again,
Both the fibonacci series and the lucas numbers are based on an identical formula.
-
we Added a third function called sum_series with one required parameter and two optional parameters. The required parameter will determine which element in the series to print. The two optional parameters will have default values of 0 and 1 and will determine the first two values for the series to be produced.
-
and after all that .. we tested the code
it took about 3 hour