<jupyter_start><jupyter_text>Project Euler: Problem 2 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.<jupyter_code>"""first few numbers : 0 1 1 2 3 5 8 13..."""

a=1
b=0
c=0
i=0
mylist=[0]

while (a<=4000000):
    c=a+b #c is the value of the sum of the previous two terms. 
    b=a   #b then becomes the term that was in front of it, a.
    a=c   # a then becomes c
    if a%2==0: #even
            mylist[i]=a
            mylist.append(a)
            i+=1 #goes to next element on the list
            
print(mylist) # THIS IS THE LIST OF ALL THE EVEN NUMBERS! not too sure why 3524578 appears twice,

del mylist[11] # so it is deleted here.
print(mylist)
answer = sum(mylist)
print(answer) # The answer is 4613732!
        


           

   



# This cell will be used for grading, leave it at the end of the notebook.<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08839285714285715, 'fraction_numerical': 0.055357142857142855, 'mean_word_length': 2.774410774410774, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '572338', 'license': 'MIT', 'n_tokens_mistral': 425, 'n_tokens_neox': 371, 'n_words': 172, 'path': 'assignments/assignment02/ProjectEuler2.ipynb', 'repo_name': 'phungkh/phys202-2015-work', 'size': '1120'}