import unittest


class TestSumFibonacci(unittest.TestCase):
    ''' Problem 2 - 19 October 2001
    Each new term in the Fibonacci sequence is generated by adding the previous
    two terms. By starting with 1 and 2, the first 10 terms will be:
    1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...'''
    def setUp(self):
        self.result = sum_fibonacci(89)

    def test_sum(self):
        self.assertEqual(self.result, 44)

def sum_fibonacci(max):
    fator1 = 0
    fator2 = 1
    soma = 0
    while fator1 + fator2 <= max:
        numero = fator1 + fator2
        fator1 = fator2
        fator2 = numero
        if numero % 2 == 0:
            soma += numero
    return soma

if __name__ =='__main__' :
    '''By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.'''
    print('resultado:',sum_fibonacci(4000000))
