In this recipe, we will sum the even-valued terms in the Fibonacci sequence whose values do not exceed 4 million. The Fibonacci series is a sequence of integers starting with zero, where each number is the sum of the previous two, except (of course) the first two numbers, zero and one (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 ...).
The sequence was published by Fibonacci in 1202 and originally did not include zero. Actually, it was already known to Indian mathematicians in earlier centuries. Fibonacci numbers have applications in mathematics, computer science, and biology.
Note
For more information, read the Wikipedia article about Fibonacci numbers at http://en.wikipedia.org/wiki/Fibonacci_number.
This recipe uses a formula based on the golden ratio, which is an irrational number with special properties comparable to pi. The golden ratio is given by the following formula:
We will use the sqrt()
, log()
, arange()
, astype()
, and sum()
functions. The Fibonacci sequence's...