You are on page 1of 1

Question: A Fibonacci number is a number that is equal to the sum of the two

preceding ones, starting from 0 and 1. Write a Python expression that calculates the
sum of the even-valued Fibonacci numbers whose values do not exceed 4 million.

1. A Fibonacci number is a number that is equal to the sum of the two preceding
ones, starting from 0 and 1. In other words, the first two Fibonacci numbers
are 0 and 1, and each subsequent Fibonacci number is the sum of the two
preceding ones.
2. The sequence of Fibonacci numbers that do not exceed 4 million is: 0, 1, 1, 2,
3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765.
3. To calculate the sum of the even-valued Fibonacci numbers, you need to loop
through the sequence and add up the even numbers.
4. Here's an example: The first few Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21,
34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765. The even-valued
Fibonacci numbers are 0, 2, 8, 34, 144, 610, 2584. The sum of these numbers is
3432.

You might also like