# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# + [markdown] nbgrader={}
# # Project Euler: Problem 2

# + [markdown] nbgrader={}
# Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 0 and 1, the first 12 terms will be:
#
# 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
#
# By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.

# + deletable=false nbgrader={"checksum": "6cff4e8e53b15273846c3aecaea84a3d", "solution": true}
Fibonacci = [0, 1]
a = 1
while Fibonacci[a] < 4000000:
    Fibonacci.append(Fibonacci[a] + Fibonacci[a - 1])
    a += 1
    
Sum = 0
for item in Fibonacci:
    if item < 4000000 and item % 2 == 0:
        Sum += item

print(Sum)

# + deletable=false nbgrader={"checksum": "e8afe8a5735f0fff949b706895f8583d", "grade": true, "grade_id": "projecteuler2", "points": 10}
# This cell will be used for grading, leave it at the end of the notebook.

StarcoderdataJupyterScriptsDedupFiltered